簡體   English   中英

將301從http重定向到https不起作用

[英]Redirect 301 from http to https doesn't work

我的共享虛擬主機中有這個.htaccess。

RewriteOptions inherit
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]


RedirectMatch 301 ^/directory(.*)$ https://www.example.com/$1
RedirectMatch 301 ^/directory/(.*)$ https://www.example.com/$1
RedirectMatch 301 ^/directory\-2014\.03\.04(.*)$ https://www.example.com/$1
RedirectMatch 301 ^/directory\-2014\.03\.04/(.*)$ https://www.example.com/$1

RewriteCond %{HTTP_HOST} ^example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^/?$ "https\:\/\/www\.example\.com\/" [R=301,L]

我希望所有對http://www.example.comhttp://example.com的調用都重定向到https://www.example.com 但是用我的設置也不起作用。

嘗試更換:

RewriteCond %{HTTP_HOST} ^domain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.domain\.com$
RewriteRule ^/?$ "https\:\/\/www\.domain\.com\/" [R=301,L]

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [L,R=301]

RewriteCond %{HTTPS} =off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NC,R=301,L]

上面的代碼首先將http://domain.com更改為http://www.domain.com然后將http://www.domain.com重定向到https://www.domain.com如果不是) https://

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM