如何允許訪問者使用此鏈接(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