見下
#escape the . so it does not match indexsphp etc
#added [NC,L] so it is not case sensitive and last rule processed
RewriteRule ^index\.php$ test.php [NC,L]
#added [NC,L] so it is not case sensitive and last rule processed
# and QSA to pass through any existing query string values
RewriteRule ^project-([0-9]+)\.html$ project.php?id=$1 [L,NC,QSA]
以下編輯代碼如果這個規則
重寫規則^ project.php?ID = 82 $ test.php的
旨在僅當id = 82時匹配,則它將不起作用並且需要被重寫如下
#if the query string has an id=82
RewriteCond %{QUERY_STRING} id=82 [NC]
#and resource is project.php, send it to test.php
RewriteRule ^project\.php$ test.php [NC,L]
編輯
我想借project.php?ID = 82,並切換到項目82.html
下面
#if the original request has project.php
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /project\.php [NC]
#capture the id param
RewriteCond %{QUERY_STRING} id=([0-9]+) [NC]
#and 301 redirect to project-id.html
RewriteRule . project-%1.html? [L,R=301]
對於非顯而易見的問題有時需要來設置[RewriteLog](http://httpd.apache.org/docs/2.0/mod/mod_rewrite的.html#rewritelog)。 – mario 2012-01-06 19:08:52