Regex .htaccess根据引用存在情况重定向

Regex .htaccess根据引用存在情况重定向,regex,.htaccess,redirect,url-redirection,Regex,.htaccess,Redirect,Url Redirection,我需要将不包含?ref=something的每个url重定向到一个固定的html页面 例如: 操作:用户导航到www.domain.com/?ref=somerefcode。结果:保持在页面上 操作:用户登录www.domain.com时不带参考标签。结果:应重定向至:www.domain.com/other_页面 多谢各位 Ronen您可以使用以下规则: RewriteCond %{QUERY_STRING} ^ref=(.*)$ RewriteRule ^ - [L] RewriteCon

我需要将不包含
?ref=something
的每个url重定向到一个固定的html页面

例如:

操作:用户导航到www.domain.com/?ref=somerefcode。结果:保持在页面上

操作:用户登录www.domain.com时不带参考标签。结果:应重定向至:www.domain.com/other_页面

多谢各位


Ronen

您可以使用以下规则:

RewriteCond %{QUERY_STRING} ^ref=(.*)$
RewriteRule ^ - [L]

RewriteCond %{REQUEST_URI} !^/other_page$
RewriteRule ^(.*)$ /other_page [R,L]
谢谢你,塞吉奥

稍微更正一下,正好符合我的问题:

RewriteCond %{QUERY_STRING} ^ref=(.*)$
RewriteRule ^ - [L]
RewriteCond %{REQUEST_URI} !^ref=(.*)$
RewriteRule ^(.*)$ /other_page [R,L]