Mod_Rewrite Questions...

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

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

Post by tecktalkcm0391 »

This still isn't working even if I go to US/New York it doens't work. and its suppost to because if i go to us.php?state=New York... it does work and shows the page.

Also with the .php if i go to anypage and then remove the .php it still doens't show up anything. I get a 404 error.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

tecktalkcm0391 wrote:This still isn't working even if I go to US/New York it doens't work. and its suppost to because if i go to us.php?state=New York... it does work and shows the page.

Also with the .php if i go to anypage and then remove the .php it still doens't show up anything. I get a 404 error.

Code: Select all

ErrorDocument 401 error.php?error=401
ErrorDocument 403 error.php?error=403
ErrorDocument 404 error.php?error=404
ErrorDocument 500 error.php?error=500

RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [S=2]
RewriteRule ^us/([A-Z]+)$ us.php?state=$1 [nocase]
RewriteRule ^(.+)/$ $1.php [QSA,L]
# The above line expects a trailing slash.
# It wont work the same without the slash
Try the one above. Take note that the trailing slash will affect the rewriting, so if you go to http://www.mysite.com/somepage/ the server should load http://www.mysite.com/sompage.php. But if you go to http://www.mysite.com/somepage, the server will look for the folder.
Post Reply