首页是使用mod_rewrite for www.test / about / somthing 它正在工作,但没有获得$ id
但我的第二页我使用mod_rewrite进行www.test / custom / somthing 它正在工作并获得$ id
然后我决定从服务器删除.htaccess并再次测试
www.test / custome / somthing<<<不工作,页面返回未找到
www.test / about / somthing<<<它仍在工作,但没有获得$ id
这是我的代码
RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]
# RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
# RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
# website rewrite down here
# -------------------------------------------------------------------
RewriteRule ^about/(.*)$ about.php?id=$1 [L]
RewriteRule ^custom/(.*)$ custom.php?id=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
帮助我,现在我身边的鬼魂:(
答案 0 :(得分:1)
您的规则不正确。
试试这段代码:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
# website rewrite down here
# -------------------------------------------------------------------
RewriteRule ^about/(.*)$ about.php?id=$1 [L,QSA]
RewriteRule ^custom/(.*)$ custom.php?id=$1 [L,QSA]
您的代码对于相同的模式/about/