2016-02-02 41 views
2

當我嘗試從URL www.mypage.com進入我的網站,我得到的東西像http://www.mypage.com/index.php/https://mypage.com/https://www.mypage.com ....WWW到非www與SSL沒有的index.php

當我從URL mypage.com我進入有https://mypage.com - 及其OK

當我從URL輸入mypage.com/stuff我https://mypage.com/index.php/stuff(頁是否正常)

當我從URL輸入www.mypage.com/stuff我https://mypage.com/index.php/stuff

我該怎麼辦?我想總是像https://mypage.com沒有index.php和沒有'WWW'的網址。

我的.htaccess:

AddHandler application/x-httpd-php70 php 
RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L] 

RewriteCond %{HTTPS} off 
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 

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

謝謝!

回答

3

試着切換周圍的秩序,使內部重定向到index.php/$ 1執行最後:

AddHandler application/x-httpd-php70 php 
RewriteEngine On 

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

RewriteCond %{HTTPS} off 
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L] 
+0

這給出了同樣的結果 – Ridd

+1

清晰的瀏覽器緩存,並重新測試。有沒有其他重寫.htaccess或主配置可能會影響結果?該PHP本身做任何URL操作或重定向? –

+0

太棒了!這很有趣,但清晰的瀏覽器緩存切換順序幫助!謝謝! – Ridd