Execute for all EXCEPT certain folder

Discussions about Apache mod Rewrite, .htaccess, Use, experiences ... URL Rewriting.

Moderator: Moderators

Execute for all EXCEPT certain folder

Postby rotwyla98 » Sun Nov 25, 2007 12:28 am

my current .htaccess code is

Code: Select all
RewriteEngine On
RewriteCond %{HTTP_HOST} !^domain.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]
RewriteRule ([^/\.]+)/$ script.php?a=$1 [L]


This basically masks
domain.com/script.php?a=anything-they-type
to
domain.com/anything-they-type/

Currently, I have a folder at domain.com/foldexists/ but when I try to go there, the htaccess rule comes to play and instead of viewing the contents of that folder, I see domain.com/script.php?a=foldexists

How can i make it so that that condition doesnt apply to foldexists?
rotwyla98
 
Posts: 6
Joined: Fri Feb 16, 2007 10:20 pm

Advertisement

Postby dcz » Sun Nov 25, 2007 3:00 pm

You could just make sure that the directory requested does not exist first :


Code: Select all
RewriteEngine On
RewriteCond %{HTTP_HOST} !^domain.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ([^/\.]+)/$ script.php?a=$1 [L]


If the full check : not a file, not a dir and not a link.
Code: Select all
RewriteCond %{REQUEST_FILENAME} !-d


is enough if you only deals with directories.
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21238
Joined: Fri Apr 28, 2006 9:03 pm

Postby rotwyla98 » Sun Nov 25, 2007 3:12 pm

works like a charm. Thanks
rotwyla98
 
Posts: 6
Joined: Fri Feb 16, 2007 10:20 pm


Return to Apache mod Rewrite

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 4 guests