本文介绍了301重定向,除了子域整个网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经建立了网站范围301在我的.htaccess重定向如下:
I have setup a sitewide 301 redirect in my .htaccess as follows
RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^.* %{SERVER_NAME}%{REQUEST_URI} [R=301,L]
不过,我想从被包括在这个重定向排除子域(支持博客)。所以,我想补充以下RewriteConditions
But I wanted to exclude subdomains (support, blog) from being included in this redirect. So I add the following RewriteConditions
RewriteEngine On RewriteCond %{HTTP_HOST} !=support.example RewriteCond %{HTTP_HOST} !=blog.example RewriteCond %{HTTPS} !=on RewriteRule ^.* %{SERVER_NAME}%{REQUEST_URI} [R=301,L]这工作完全正常。不过,我不知道是否有更好的方法,在短短1的RewriteCond声明(而不是为每个子域单独的RewriteCond)
This works totally fine. However I wonder if there is a better way to specify the exclusion for all subdomains (not WWW) in just 1 RewriteCond statement (instead of a separate RewriteCond for each subdomain)
我有几个子域,并计划增加一些。请问AP preciate的帮助。
I have a few more subdomains and plan to add some more. Would appreciate the help.
推荐答案您可以使用此规则:
RewriteCond %{HTTP_HOST} ^(www\.)?example\$ [NC] RewriteCond %{HTTPS} !=on RewriteRule ^ %{HTTP_HOST}%{REQUEST_URI} [R=301,L]更多推荐
301重定向,除了子域整个网站
发布评论