I want to remove webpage extension from URL,somebody gave me the code for .htaccess. But it works on localhost when I turn on rewrite module.But when I use it on Godaddy it doen't work.and also when I visit example.com/cool.php it says 404 not found But I want it to be redirect if some visit example.com/cool.php to example.com/cool.... and also help about godaddy rewrite module I contacted them they haven't replied me yet. Here below is the code the guy gave to me..Thanks
RewriteEngine On
RewriteBase /
# remove enter code here.php; use THE_REQUEST to prevent infinite loops
RewriteCond %{THE_REQUEST} ^GET\ (.*)\.php\ HTTP
RewriteRule (.*)\.php$ $1 [R=301]
# remove index
RewriteRule (.*)/index$ $1/ [R=301]
# remove slash if not directory
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /$
RewriteRule (.*)/ $1 [R=301]
# add .php to access file, but don't redirect
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1\.php [L]
Assuming you want to show the "pretty" URL (
example.com/cool
) but still get the data from the original request (example.com/cool.php
), you may try this in the .htaccess file at root directory:Updated to work with php files at any directory: