2010-11-28 44 views
0

我有麻煩讓我重寫規則正常工作...htaccess的重寫規則麻煩

ErrorDocument 404 /404.php 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_URI} !^companies/ 
RewriteRule ^companies\/\?(.*)([A-Za-z]+) index.php?cpy=$1 [R=301,L,NC] 

RewriteRule ^([0-9]+)/?$ index.php?cid=$1 [L] 
RewriteRule ^([A-Za-z_]+)/?$ index.php?cat=$1 [L] 

爲 domain.com/123 domain.com/abc 重寫規則似乎好的工作,

但另一位我不能去工作 domain.com/companies/?list=this

看來,阿帕奇沒有找到

匹配
RewriteRule ^companies\/\?(.*)([A-Za-z]+) index.php?cpy=$1 [R=301,L,NC] 

誰能幫我弄清楚什麼是錯的規則?或者如果它是別的東西?

回答

0

RewriteRule■不要匹配查詢字符串作爲一項規則。

你可以匹配他們使用RewriteCond與表現爲%1, %2的參數匹配等

如。

RewriteCond %{QUERY_STRING} ^(.*)([A-Za-z]+)$ 
RewriteRule ^companies\/ index.php?cpy=%1 [R=301,L,NC] 
+0

感謝您的澄清。我不知道,和你能想象它使所有的差異在世界上,當你正在努力尋找匹配。我最終使用的代碼(很好用)是RewriteCond%{QUERY_STRING} ^(。*)([A-Za-z] +) RewriteRule^companies \//index.php?cpy=%1%2 [ L] – kris 2010-11-29 04:33:10