tags:

views:

16

answers:

1

This is the file tree:

  • /problem/
  • /problem/index.php
  • index.php
  • category.php
  • somefile.php

I have this 2 rules in the .htaccess that is sitting in the /

RewriteRule ^somedir$ /somefile.php [L]
RewriteRule ^([a-z-]+)$ /category.php?cat=$1 [QSA,L]

So...

I need to add a rule that doesn't add the cat=$1 when the /dir/ exists.

+2  A: 

Just add a RewriteCond before your second rule. Basically, don't run that catch all if it starts with product:

RewriteRule ^somedir$ /somefile.php [L]
RewriteCond %{REQUEST_URI} !^/product [NC]
RewriteRule ^([a-z-]+)$ /category.php?cat=$1 [QSA,L]

To prevent redirecting for a real file or directory, add these two lines before the rule:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
Doug Neiner
that worked fine! is there a way to add a RewriteCond for all physical existing directories?
andufo
Yes, I updated my answer to reflect your question.
Doug Neiner