Remove .php from urls with htaccess

前端 未结 5 1690
抹茶落季
抹茶落季 2020-11-27 04:20

EDIT: current .htaccess file:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

## hide .php extension snippet

# To          


        
5条回答
  •  醉话见心
    2020-11-27 04:38

    On apache 2.4 and later, You can use the following Rule with END flag to remove .php extension from urls.

    RewriteEngine on
    
    RewriteRule ^(.+)\.php$ /$1 [NC,L,R=301]
    RewriteCond %{REQUEST_FILENAME}.php -f
    RewriteRule ^(.+)/?$ /$1.php [END]
    

提交回复
热议问题