2017-08-04 63 views
0

訪問以下任何鏈接都可以正常工作,並且網址中沒有/index.php當通過HTTP查看網站時,URL顯示URL中的/index.php,但使用HTTPS時不顯示網址

1)https://kdev.solutions

2)https://www.kdev.solutions

但是,如果您嘗試使用HTTP訪問該網站,你會被重定向到HTTPS版本,但會有在URL /index.php現在。我如何擺脫這一點?

1)http://kdev.solutions

2)http://www.kdev.solutions

這裏是我的.htaccess文件:

<IfModule mod_rewrite.c> 
    <IfModule mod_negotiation.c> 
     Options -MultiViews 
    </IfModule> 

    RewriteEngine On 

    #get rid of index.php in home 
    RedirectMatch 301 ^/index.php/(.*)$ https://kdev.solutions/$1 

    # Handle Front Controller... 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteRule^index.php [L] 

    # Handle Authorization Header 
    RewriteCond %{HTTP:Authorization} . 
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 

    # redirect to HTTPS 
    RewriteCond %{HTTPS} off 
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} 

    # Redirect Trailing Slashes If Not A Folder... 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)/$ /$1 [L,R=301] 
</IfModule> 

回答

0

刪除這一行:

RedirectMatch 301 ^/index.php/(.*)$ https://kdev.solutions/$1 

這CONFIGS足夠˚F或重定向非HTTPS到HTTPS(你已經擁有它):

RewriteEngine On 
RewriteCond %{HTTPS} off 
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} 
+0

當我在地址欄中輸入「kdev.solutions」或「www.kdev.solutions」時,我仍然在URL中獲得'/ index.php'。 – Attila

0

您需要通過保持所有之前的內部重寫規則,重定向規則來重新排序規則:

<IfModule mod_rewrite.c> 
    <IfModule mod_negotiation.c> 
     Options -MultiViews 
    </IfModule> 

    RewriteEngine On 

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

    # Redirect Trailing Slashes If Not A Folder... 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)/$ /$1 [L,R=301,NE] 

    # remove index.php 
    RewriteCond %{THE_REQUEST} /index\.php [NC] 
    RewriteCond %{REQUEST_URI} ^(.*/)index\.php$ [NC] 
    RewriteRule^%1 [L,R=301,NE]  

    # Handle Front Controller... 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteRule^index.php [L] 

    # Handle Authorization Header 
    RewriteCond %{HTTP:Authorization} . 
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 

</IfModule> 

另外,還要確保你清楚你的瀏覽器緩存或在新瀏覽器中測試。

+0

如果我使用該文件,當我導航到網站時,可以獲得此文件:https://s20.postimg.org/y9u4gbtb1/webpage.jpg – Attila

+0

在新瀏覽器中嘗試更新的規則。 – anubhava

+0

如果我使用不同的瀏覽器,它沒有區別:( – Attila

相關問題