Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My site uses mod_rewrite for most URL's within the site. eg.

I've had working for a long time and is quite simple, but unfortunately I cannot for the life of me get subfolder rewrites working so that I can go to without it taking me straight to a 404 page. Here is an excerpt from my .htaccess.

RewriteRule ^product1/([^/]+).htm$ /product1/index.php?p=$1 [L] #Even hardcoded isn't working...
RewriteRule ^([^/]+)/([^/]+)/([^/]+).htm$ /$1/$2/index.php?p=$3 [L]
RewriteRule ^([^/]+)/([^/]+).htm$ /$1/index.php?p=$2 [L]
RewriteRule ^([^/]+).htm$ /index.php?p=$1 [L]

These rules work fine on but never seem to work in practice. I'd love some help on this.

Edit: FYI, this is a singular .htaccess file located in the root www folder of


share|improve this question

migrated from Jun 24 '11 at 9:22

This question came from our site for professional and enthusiast programmers.

Are those all of your rules? You might have conflicting rules somewhere. – Jacob Eggers Jun 23 '11 at 23:17
Yes, these are all of the rules I use. – Craig White Jun 23 '11 at 23:18
Perhaps this question belongs on Webmasters? – 40XUserNotFound Jun 23 '11 at 23:26

D'oh!.... Ok, apache obviously didn't like me having a .htaccess file within the subfolder with RewriteEngine On even though there weren't any rules. I removed the RewriteEngine On and it worked. Bam. 2 Evenings gone.

Thanks anyway guys.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.