仅当不存在 URL 查询字符串时才在子域上重定向页面
Redirect page on subdomain only when no URL query string is present
非常具体的 htaccess 问题:我在 http://subdomain.example.com/page/ that contains a form. The page should only be accessed with auto-created links that contain query strings that feed information through the form. What I need is an htaccess rule that will redirect traffic coming to this page to my homepage at http://example.com/ 有一个页面,每当到达 时 URL 中没有查询字符串。
换句话说:如果有人到达 http://subdomain.example.com/page/ they need to redirect to http://example.com. But if someone reaches 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]
非常具体的 htaccess 问题:我在 http://subdomain.example.com/page/ that contains a form. The page should only be accessed with auto-created links that contain query strings that feed information through the form. What I need is an htaccess rule that will redirect traffic coming to this page to my homepage at http://example.com/ 有一个页面,每当到达 时 URL 中没有查询字符串。
换句话说:如果有人到达 http://subdomain.example.com/page/ they need to redirect to http://example.com. But if someone reaches 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]