I just wanted to do a simple thing with mod_rewrite. I have a site that uses .php files, and I wanted to rewrite them to cleaner URLs and remove the .php. So the files would be www.mysite.com/contact etc.
This works the way I wanted, but I expected it to serve my contact.php file anyway, but just show the user that they are in / contact, not contact.php. But he is looking for a file, the contact just called, which is not there.
So what I need to do, still use my contact.php file, but rewrite the url for the user / contact?
Here is what I use:
SetEnv APPLICATION_ENV development
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^mysite\.com$ [NC]
RewriteRule ^(.*)$ http://www.mysite.com/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^www\.mysite\.com$ [NC]
RewriteRule ^(.*)\.php$ http://www.mysite.com/$1 [L,R=301]
source
share