Remove .php extension with .htaccess

前端 未结 15 2223
一生所求
一生所求 2020-11-21 04:32

Yes, I\'ve read the Apache manual and searched here. For some reason I simply cannot get this to work. The closest I\'ve come is having it remove the extension, but it point

15条回答
  •  暖寄归人
    2020-11-21 05:03

    To remove the .php extension from a PHP file for example yoursite.com/about.php to yoursite.com/about Follow these step . Open .htaccess(create new one if not exists) file from root of your website, and add the following code.

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^\.]+)$ $1.php [NC,L]
    

    To remove the .html extension from a html file for example yoursite.com/about.html to yoursite.com/about Follow these step .

    Open .htaccess(create new one if not exists) file from root of your website, and add the following code.

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^\.]+)$ $1.html [NC,L]
    

    Reference: How to Remove php Extention from URL

提交回复
热议问题