简体   繁体   English

如何在url中删除index.php? (laravel 5.3,php 7)

[英]How to remove index.php in url ? (laravel 5.3, php 7)

My url is like this : http://31.220.56.75/mysystem/public/index.php/login 我的网址是这样的:http: //31.220.56.75/mysystem/public/index.php/login

I want remove index.php, to be like this : http://31.220.56.75/mysystem/public/login 我想删除index.php,如下所示:http: //31.220.56.75/mysystem/public/login

My .htaccess : 我的.htaccess:

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

    RewriteEngine On

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

    # 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>

I try some tutorial di google. 我尝试了一些教程di google。 but I don't find the solution 但我找不到解决方案

Update : 更新

I try update .htaccess like this : 我尝试像这样更新.htaccess:

<IfModule mod_rewrite.c>
   RewriteEngine On 
   RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

It's not working 它不起作用

Try this 尝试这个

<IfModule mod_rewrite.c>
 RewriteEngine On 
  RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

default .htaccess in public folder should be working very fine. 公用文件夹中的默认.htaccess应该工作得很好。 check: original .htaccess 检查: 原始.htaccess

Follow the below .htaccess file, hopefully this will work. 按照下面的.htaccess文件,希望这将工作。

If your are facing the issue of $_GET variable also ie If your both URL index.php and without index.php is working but $_GET variables found not working, then the below of .htaccess code will work for you. 如果您正面临$ _GET变量的问题,即如果你的URL index.php和没有index.php都工作但是找不到$ _GET变量,那么下面的.htaccess代码将适合你。

DirectoryIndex index.php
<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On
    RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
    RewriteRule ^(.*) - [E=BASE:%1]
    RewriteCond %{ENV:REDIRECT_STATUS} ^$
    RewriteRule ^index\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule .? - [L]
    RewriteRule .? %{ENV:BASE}/index.php [L]

</IfModule>

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

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