2014-11-24 176 views
0

我去了整個網站只能使用https進行聯繫。問題htacess重定向從http到https

.htaccess到我寫了下面的規則

RewriteEngine On 
RewriteCond %{HTTP_HOST} ^www.my-website.com [NC] 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.my-website.com/$1 [R,L] 

但它會導致「此網頁有重定向循環」 任何人都可以指導我修復此。

+0

使用[不建議您使用情況的mod_rewrite(https://wiki.apache.org/httpd/RedirectSSL)。但是,你真的不得不嘗試[這個例子](https://wiki.apache.org/httpd/RewriteHTTPToHTTPS)。 – 2014-11-24 15:23:10

回答

0

通常用一個單一的網站,你可以使用:

RewriteEngine on 
RewriteCond %{HTTPS} off 
RewriteRule^https://www.my-website.com%{REQUEST_URI} [R=301,L]