negation string

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
keenlearner
Forum Commoner
Posts: 50
Joined: Sun Dec 03, 2006 7:19 am

negation string

Post by keenlearner »

Hi, i am trying to make database driven website and using .htaccess to make nice url. Regex for .htaccess has been put on the root of the localhost server.

RewriteEngine on
RewriteRule ^([a-zA-Z0-9-]+)$ /$1/ [R=301]
RewriteRule ^([a-zA-Z0-9-]+)/$ main.php?page=$1

The first one is to direct the url that not ended with trailing slash to url with trailing slash, this is not a problem. However the second one give me a problem, if my website http://www.example.com/ already up with control panel known as cpanel , so if I request the url http://www.example.com/cpanel/ it will direct the page to main.php?page=cpanel which is not what I want. So I am trying to figure out how can I make an negation string for "cpanel" . How can I make the RewriteCond so that it will check if the url that is http://www.example.com/cpanel/ will not rewrite the url to main.php?page=cpanel
how do i make negation string for cpanel ?
I used this
RewriteCond %{REQUEST_URI} ^!(/cpanel/)$ but does not work.

Thanks.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

The exclamation appears before the pattern, not in it. ;)
keenlearner
Forum Commoner
Posts: 50
Joined: Sun Dec 03, 2006 7:19 am

Love you so much....

Post by keenlearner »

Love so much feyd....it took me 5 hours to figure that problem, but actually a little mistake of placing the '!" sign, Thanks.
Post Reply