2017-08-04 40 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

相关问题