Page 1 of 1

More Mod_Rewrite --- I'm still learning, but please help.

Posted: Sun Sep 10, 2006 8:29 am
by tecktalkcm0391
I have this in the .htaccess on the base of my site (site.com)

Code: Select all

RewriteCond %{THE_REQUEST} ^GET\ (.*)\.php\ HTTP 
RewriteRule (.*)\.php$ $1 [R=301]
Thas gets rid of the .php on any site page, but how can I turn that off for http://site.com/folder?

Also, I have this:

Code: Select all

RewriteRule ^us/([A-Za-z]+)/([A-Za-z0-9]+)/$ us.php?state=$1&page=$2 [NC]
When ever I go to US/Florida/ its gives me a 404 error when it should show up a default page.
When ever I go to US/Florida/Page1 it works.

But when ever I use the US/State/Page... the page doesn't really work because of its links to files in other folders (example. stylesheet in site.com/css)

Why is that happening?

Re: More Mod_Rewrite --- I'm still learning, but please help

Posted: Mon Sep 18, 2006 2:46 am
by arkady
tecktalkcm0391 wrote:I have this in the .htaccess on the base of my site (site.com)

Code: Select all

RewriteCond %{THE_REQUEST} ^GET\ (.*)\.php\ HTTP 
RewriteRule (.*)\.php$ $1 [R=301]
Thas gets rid of the .php on any site page, but how can I turn that off for http://site.com/folder?

Also, I have this:
Try popping a .htaccess file in that subdirectory turning Rewrite Off.

Code: Select all

RewriteRule ^us/([A-Za-z]+)/([A-Za-z0-9]+)/$ us.php?state=$1&page=$2 [NC]
When ever I go to US/Florida/ its gives me a 404 error when it should show up a default page.
When ever I go to US/Florida/Page1 it works.

But when ever I use the US/State/Page... the page doesn't really work because of its links to files in other folders (example. stylesheet in site.com/css)

Why is that happening?
You're likely using relative paths to the images/files etc... so what you'd probably want to do is change the generated links (based on the header info) to be something like ../../mystylesheet.css where the page is US/Florida/blah.php etc.. Don't forget that as far as the page is concerned it is actually at that /US/Florida location, apache does all the necessary translation to make it work.