0
我希望你能幫忙解決這個htaccess問題嗎?我基本上有一個場景中除了htaccess的規則。用戶通過非HTTPS和非WWW鏈接訪問網站時就是這種情況。如何將非WWW,非HTTPS重定向到WWW,沒有多重重定向的HTTPS?
重新定向上的http /非WWW URL
- 用戶訪問
- 用戶最初重定向到HTTP/WWW URL然後
- 用戶被重定向到https://www.website
你可以看到這裏的行爲:
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
這裏沒有顯示添加'www'並保留'http' URL的規則。你在Apache配置中還有一些規則嗎? – anubhava