• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 675
  • Last Modified:

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

0
SiobhanElara
Asked:
SiobhanElara
1 Solution
 
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

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now