开发者

Htaccess rewrite rules trouble

开发者 https://www.devze.com 2023-01-27 19:26 出处:网络
I am having troubles getting my rewrite rules to work correctly.. ErrorDocument 404 /404.php RewriteCond %{REQUEST_FILENAME} !-f

I am having troubles getting my rewrite rules to work correctly..

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]

The rewrite rules for domain.com/123 domain.com/abc seem to work ok,

but the other one I cannot get to work is domain.com/companies/?list=this

It seems that apache doesn't find a match for

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

Can anyone help me figure out what is wrong with that rule? or if it is something else?


RewriteRules do not match on query strings as a rule.

You can match on them using RewriteCond with the parameterized matches appearing as %1, %2, etc.

eg.

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

精彩评论

暂无评论...
验证码 换一张
取 消