Quick Mod_Rewrite Question

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Quick Mod_Rewrite Question

Post 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]
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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])
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Post 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.
Post Reply