Home » Php » How to add .php extension in htaccess in Laravel

How to add .php extension in htaccess in Laravel

Posted by: admin February 25, 2020 Leave a comment

Questions:

I have tried everything form StackOverflow but nothing works.

At this moment my website is like www.domain.com/xxx

A want to it like www.domain.com/xxx.php

Here is my .htaccess file

#    <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>
How to&Answers:

And I found another .htaccess file in public folder

here it goes:

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