从URL Laravel 5删除的index.php [英] Remove index.php from url Laravel 5

查看:835
本文介绍了从URL Laravel 5删除的index.php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

网址是在我的应用程序工作正常。我的意思是他们是pretty的URL。例如 http://www.example.com/
但是,当您访问的页面也适用的index.php 例如 HTTP ://www.example.com/index.php ,我不希望因为它显示了一个页面在网站地图两个环节。没有一个页面的的index.php 并与另一的index.php 。网站地图的演示是在这里 https://www.xml-sitemaps.com/details -eln.6762418.html

下面是在的.htaccess

 < IfModule mod_rewrite.c>
    < IfModule mod_negotiation.c>
        选项​​-MultiViews
    < / IfModule>    RewriteEngine叙述在    #重定向结尾斜杠...
    重写规则^(。*)/ $ / $ 1 [L,R = 301]    #手柄前端控制器...
    的RewriteCond%{} REQUEST_FILENAME!-d
    的RewriteCond%{} REQUEST_FILENAME!-f
    重写规则^的index.php [L]
< / IfModule>


解决方案

将下面的code:

  RewriteEngine叙述在
的RewriteBase /的RewriteCond%{} THE_REQUEST /指数[NC]
重写规则^ / [R = 302,L,NE]

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>

解决方案

Put the following code :

RewriteEngine On
RewriteBase /

RewriteCond %{THE_REQUEST} /index [NC]    
RewriteRule ^ / [R=302,L,NE]

这篇关于从URL Laravel 5删除的index.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆