View Full Version : url rewrite regex help ??

05-14-2008, 07:00 AM
Hello forums
I have some problem regarding regex in url rewriting.

Options -Indexes
Options +FollowSymlinks

RewriteEngine on
RewriteRule ^admin/(.*)$ admin_$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
# Main URL rewriting.
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

Everything works fine except for admin part.
When admin/any_text comes in url, it routes to admin_any_text. but i want resitriction in some cases as i have folder structure for admin as:

I want to modify rule: RewriteRule ^admin/(.*)$ admin_$1 [L] so that it doesn't rewrite for admin/js,admin/themes
How to accomplish this ?
Thanks in advance for the valueable suggestions.

05-14-2008, 05:00 PM
You can add a RewriteRule before your main admin one like this:

RewriteRule ^admin/(js|themes) - [L]
RewriteRule ^admin/(.*)$ admin_$1 [L]

That will specify no rewrite for the matched pattern, terminating rewriting using [L].

06-13-2008, 07:18 AM
I am reopening this thread because this regex didn't worked in live server
though it worked perfectly in localhost.
In the live server apache is V1.3. I think the regex is not running its because of assertion type.
The error shown by the server is compilation error.
Is there any alternatives for this regex that doent use assertion.

Thanks in advance for the valueable help.

06-13-2008, 04:33 PM
I have no idea what 'assertion' you're talking about. Nothing discussed is an assertion in any sense I understand the term.

Maybe it would be helpful if you pasted the actual error output from the server.