Remove index.php from url Laravel 5

2019-07-10 08:19发布

URLs are working fine in my application. I mean they are pretty URLs. Like http://www.example.com/ But it also works when you access the page with index.php like http://www.example.com/index.php, which I don't want because it is showing two links in sitemap for one page. One page without index.php and another with index.php. Demonstration of the sitemap is here https://www.xml-sitemaps.com/details-eln.6762418.html

Here is the .htaccess

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

    RewriteEngine On

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

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

1条回答
女痞
2楼-- · 2019-07-10 08:42

Put the following code :

RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,7}\s/(.*)index\.php\sHTTP.*$
RewriteRule ^ /%1 [R=301,L]
查看更多
登录 后发表回答