这就是我要做的事情:
/subdomain/?q=Keyword+Search -> /?q=Keyword+Search
/subdomain?q=Keyword+Search -> /?q=Keyword+Search
/subdomain/view.php?id=1 -> /subdomain/view.php?id=1
我正在尝试这样做(结果发表评论)
#/subdomain/?q=Keyword+Search -> /?q=Keyword+Search
RewriteRule ^subdomain/(.*) /$1 [R=301,L] #redirects /subdomain/view.php to /view.php
RewriteRule ^subdomain/?(.*) /?$1 [R=301,L] #redirects /subdomain/* to /
RewriteRule ^subdomain/ / [R=301,L] #redirects /subdomain/* to /
我在这里做错了什么?
答案 0 :(得分:2)
您可以将此规则用于负前瞻:
RewriteRule ^subdomain/((?!view\.php).*)$ /$1 [R=301,L,NC]
或者使用RewriteCond
:
RewriteCond %{REQUEST_URI} !^/subdomain/(view|edit|reports|stats)\.php$ [NC]
RewriteRule ^subdomain/(.*)$ /$1 [R=301,L,NC]