2016-05-25 38 views
3

我試圖重定向通過HTTPS所有流量裸域SSL這是我的htaccess文件:重定向所有流量使用htaccess的

<IfModule mod_rewrite.c> 
Options +FollowSymLinks -Indexes 
    RewriteEngine on 
    RewriteCond %{HTTPS} off 
    RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] 
    RewriteRule^https://%1%{REQUEST_URI} [R=301,L] 
    RewriteBase/

    RedirectMatch 301 /index.php/(.*)$ /$1 

    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)$ index.php?/$1 [L] 
</IfModule> 
<IfModule !mod_rewrite.c> 
    ErrorDocument 404 index.php 
</IfModule> 

目前這裏發生了什麼事情,

如果用戶類型www.domain.com它重定向到:https://domain.com這是很好的。我想在配置文件中的幫助,這樣,如果用戶還類型domain.com他們重定向到https://domain.com

回答

2

這將是更新您的模式非常簡單:

RewriteEngine on 
RewriteCond %{HTTPS} off 
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC] 
RewriteRule^https://%1%{REQUEST_URI} [R=301,L] 
+0

你先生是正確的。我在你回答時更新了模式,它確實有效。 非常感謝。 –

相關問題