簡體   English   中英

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

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

我的網址是這樣的:http: //31.220.56.75/mysystem/public/index.php/login

我想刪除index.php,如下所示:http: //31.220.56.75/mysystem/public/login

我的.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>

我嘗試了一些教程di google。 但我找不到解決方案

更新

我嘗試像這樣更新.htaccess:

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

它不起作用

嘗試這個

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

公用文件夾中的默認.htaccess應該工作得很好。 檢查: 原始.htaccess

按照下面的.htaccess文件,希望這將工作。

如果您正面臨$ _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