How to make a directory an exception in my .htaccess rewrite?

I'm completely new to the concept of using the rewrite engine to change URLs, but have a site where I want URLs looking like www.mysite.com/about to go to www.mysite.com/index.cfm?page=about. I added an .htaccess file with the code below and everything was grand.

The problem, I just realized, is that the site also has an administration subdirectory at www.mysite.com/admin. If you try to access www.mysite.com/admin/index.cfm it works fine, but www.mysite.com/admin alone obviously gets redirected.

Is there a way to either 1) specify that redirects should only work for files in the root directory or 2) redirect everything unless the URL contains /admin?

Thank you!
RewriteEngine on
RewriteRule ^([^/\.]+)/?$ index.cfm?page=$1 [NC]

Open in new window

SiobhanElaraAsked:
Who is Participating?
 
caterham_wwwCommented:
> Is there a way to either 1) specify that redirects should only work for files in the root directory

Your regular expression has already such a restriction and won't match /foo/bar
2)
RewriteEngine on
RewriteCond $1 !^admin
RewriteRule ^([^/\.]+)/?$ index.cfm?page=$1 [NC]

Open in new window

0
 
SiobhanElaraAuthor Commented:
Just what I needed... thank you!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.