Removing .php file extension with .htaccess file

后端 未结 5 1376
误落风尘
误落风尘 2020-12-10 16:28

I want www.example.com/about.php to just be www.example.com/about

I created an .htaccess file and placed it in the root of my server. I am using linux shared hosting

5条回答
  •  盖世英雄少女心
    2020-12-10 17:00

    So after a long bout with google I finally figured this one out. This works with Godaddy shared hosting. It removes php file extensions so http://yoursite.com/about.php becomes http://yoursite.com/about

    Options -MultiViews
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f    #If requested is not a filename...
    RewriteCond %{REQUEST_FILENAME} !-d    #And not a directory
    RewriteRule ^(.*)$ $1.php [L]          # perform this redirect
    

    (remove comments before uploading to server)

提交回复
热议问题