如何在Laravel中的htaccess中添加.php扩展名

问题描述 投票:1回答:2

我已经尝试了所有形式的StackOverflow,但没有任何效果。

此刻,我的网站就像www.domain.com/xxx

想要像www.domain.com/xxx.php的它

这是我的.htaccess文件

#    <IfModule mod_negotiation.c>
#        Options -MultiViews -Indexes
#    </IfModule>
#    
#    RewriteEngine On
#
#    # Handle Authorization Header
#    RewriteCond %{HTTP:Authorization} .
#    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
#
#    # Redirect Trailing Slashes If Not A Folder...
#    RewriteCond %{REQUEST_FILENAME} !-d
#    RewriteCond %{REQUEST_URI} (.+)/$
#    RewriteRule ^ %1 [L,R=301]
#
#    # Handle Front Controller...
#    RewriteCond %{REQUEST_FILENAME} !-d
#    RewriteCond %{REQUEST_FILENAME} !-f
#    RewriteRule ^index.php [L]
#</IfModule>

<IfModule mod_rewrite.c>


RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]

</IfModule>
php laravel .htaccess
2个回答
0
投票

尝试如下。

RewriteEngine On
RewriteCond %{REQUEST_URI} !\.[a-zA-Z0-9]{3,4}
RewriteCond %{REQUEST_URI} !/$
RewriteRule ^(.*)$ %{REQUEST_FILENAME}.php

0
投票

并且我在公用文件夹中找到另一个.htaccess文件

这里:

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

    RewriteEngine On



    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

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

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>
© www.soinside.com 2019 - 2024. All rights reserved.