htaccess重写url - 将文件夹重定向到php文件

时间:2012-02-23 04:03:37

标签: .htaccess

我想将子目录重定向或重写为PHP文件

如:

http://www.domain.org/contact

到此:

http://www.domain.org/index.php?sub=contact

我真的很喜欢PHP只能将domain.org/index.php?sub=contact读取为domain.org/contact,但如果它只是重​​定向那样我会很开心!我使用.htaccess搜索了许多解决方案,但它们不清楚,或者我无法让它们专门用于我正在尝试的工作

由于

1 个答案:

答案 0 :(得分:7)

试试这个

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php?sub=$1
相关问题