Page 1 of 1

Quick Mod_Rewrite Question

Posted: Mon Oct 23, 2006 9:18 pm
by tecktalkcm0391
How would I make it so that when a user goes to http://site.com/file.php it automatically refreshed to http://site.com/file ??? I am having so much trouble with this.

I've tried

Code: Select all

RewriteCond %{REQUEST_FILENAME}.php
RewriteRule ^(.+)$ /$1 [R=301]

Posted: Tue Oct 24, 2006 12:48 am
by timvw
Could you explain us why exactly you've tried the rewrite condition and rule you posted here...I find it hard to see why someone would choose the REQUEST_FILENAME variable (the full local filesystem path to the file or script matching the request) in order to achieve what you're trying to do (rewriting ^/(.*?)\.php$ to /$1 [L])

Posted: Tue Oct 24, 2006 5:40 pm
by tecktalkcm0391
I have no clue why I was looking at some examples and thought that would work, but I tried it and it didn't.

I just want to get it to be like this for rule

If file is a .php file then it will refresh and remove the .php extension.