2010-11-28 73 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