如何允许访问者使用此链接(www.example.com/news?id=34)以查看(www.example.com/index.php?page=news & ID = 34).htaccess中的QUERY_STRING重定向时
现在我隐藏了我的PHP文件的扩展,以使链接看起来不错。当访问者访问(www.example.com/news)时,他们可以看到该页面(www.example.com/index.php?page=news)。但是,当他们转到(www.example.com/news?id=12)时,他们会收到404错误。
此时,PHP无法识别id参数。这是我目前在我的.htaccess文件中的内容
Options +FollowSymlinks
RewriteEngine on
# catch request with no querystring like /Home
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^([^/]+)$ /index.php?page=$1 [L]
# make other requests with a non-empty query string go to /index.php?id=XXXXX
RewriteCond %{QUERY_STRING} ^.*$
RewriteRule ^$ /index.php?id=$1 [QSA,L]
我真的真的真的真的真的很感谢你的帮助。你完全保存了我的一天。 – 2010-10-02 17:47:21
@Eyad:很高兴帮助! – 2010-10-02 17:54:55