我需要的是,如果有人会点击 mydomain.com/mydirectory/about-us-new,那么它应该留在页面上,如果有人点击同一域上的任何其他 url,它应该将用户重定向到 google.com。
我为此目的使用以下代码:
#urls to exclude
RewriteCond %{REQUEST_URI} !^/mydirectory/about-us-new$
#send to root
RewriteRule . http://google.com? [R=302,L]
我需要的是,如果有人会点击 mydomain.com/mydirectory/about-us-new,那么它应该留在页面上,如果有人点击同一域上的任何其他 url,它应该将用户重定向到 google.com。
我为此目的使用以下代码:
#urls to exclude
RewriteCond %{REQUEST_URI} !^/mydirectory/about-us-new$
#send to root
RewriteRule . http://google.com? [R=302,L]
尝试转义重写条件
RewriteCond %{REQUEST_URI} !^/mydirectory/about\-us\-new$
您在上面提供的重写代码对我有用。
如果安装了 mod_rewrite,您可以尝试确保启用 RewriteEngine。
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/some/url/here$
RewriteRule . http://www.google.com? [R=302,L]
</IfModule>