简体   繁体   English

从网址Laravel 5中删除index.php

[英]Remove index.php from url Laravel 5

URLs are working fine in my application. URL在我的应用程序中运行良好。 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. http://www.example.com/一样,但是当您使用index.php这样的页面(例如http://www.example.com/index.php)访问该页面时,它也可以工作,因为它显示两个站点地图中的一页链接。 One page without index.php and another with index.php . 一页没有index.php ,另一页没有index.php Demonstration of the sitemap is here https://www.xml-sitemaps.com/details-eln.6762418.html 站点地图的演示在这里https://www.xml-sitemaps.com/details-eln.6762418.html

Here is the .htaccess 这是.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>

Put the following code : 输入以下代码:

RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,7}\s/(.*)index\.php\sHTTP.*$
RewriteRule ^ /%1 [R=301,L]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM