我希望你能帮我解决这个问题?基本上,我的htaccess规则只在一个场景中起作用。当用户通过非HTTPS和非WWW链接访问站点时,就是这种情况。
重定向
你可以看到这里的行为:
http://childrens-curtains.co.uk
所有其他场景都可以正常工作。
我想尝试从序列中删除第二次重定向,因此它的行为如下:
用户访问http并立即重定向到https/www版本,而无需第二步(如果这有意义的话?)
当前的场景会导致多个重定向,我认为从SEO的角度来看,这是一个糟糕的方法。
这是我的htaccess重定向规则:
RewriteEngine On
# This will enable the Rewrite capabilities
RewriteCond %{HTTPS} !=on
# This checks to make sure the connection is not already HTTPS
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [L,R=301]
# This rule will redirect users from their original location, to the same location but using HTTPS.
# The leading slash is made optional so that this will work either in httpd.conf
# or .htaccess context发布于 2015-05-20 12:31:01
您可以尝试将此代码保留到.htaccess文件中。
若要添加www,请添加以下代码。
RewriteCond %{HTTP_HOST} ^**domainname**\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.domainname\.com$
RewriteRule ^index\.html$ "http\:\/\/www\.domainname\.com\/" [R=301,L]若要添加http,请添加以下代码。
RewriteCond %{HTTP_HOST} ^domainname.com [NC]
RewriteRule ^(.*)$ http://www.domainname.com/$1 [L,R=301]它将同时添加http和www到URL。
谢谢。
https://stackoverflow.com/questions/30319927
复制相似问题