[英]Redirect page on subdomain only when no URL query string is present
非常具体的htaccess问题:我在http://subdomain.example.com/page/上有一个包含表单的页面。 仅应使用包含查询字符串的自动创建链接访问该页面,查询字符串通过表单提供信息。 我需要的是htaccess规则,该规则可将到达此页面的访问量重定向到http://example.com/上的我的主页,只要访问量在URL中没有查询字符串即可。
换句话说,如果有人到达http://subdomain.example.com/page/,他们需要重定向到http://example.com 。 但是,如果有人到达http://subdomain.example.com/page/?querystring,他们需要停留在页面上。
如何使用htaccess解决此问题?
尝试:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^subdomain\.example\.com$ [NC]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^page/ http://example.com/ [L,R]
要么
RewriteEngine On
RewriteCond %{HTTP_HOST} ^subdomain\.example\.com$ [NC]
RewriteCond %{THE_REQUEST} !\?
RewriteRule ^page/ http://example.com/ [L,R]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.