mod_rewrite

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
someberry
Forum Contributor
Posts: 172
Joined: Mon Apr 11, 2005 5:16 am

mod_rewrite

Post by someberry »

(Wasn't sure where to post this, if you think it is better suited in the regex forum then feel free to move :))

Hi, got a wee mod_rewrite problem.

I want to route all requests to a site through index.php. The mod_rewrite I have is:

Code: Select all

RewriteEngine On
RewriteRule ^[^plugin|Public|template].*?     index.php [L]
As you can (hopefully) see from the above, I only want to route requests which aren't in the parent directory of plugin, Public, or template. But for some reason it isn't working! It works for some pages, but for ones like 'example.org/error' and 'example.org/test' it doesn't work.

Any ideas?
Thanks :)
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: mod_rewrite

Post by Christopher »

I think you want to use (plugin|Public|template) instead.
(#10850)
someberry
Forum Contributor
Posts: 172
Joined: Mon Apr 11, 2005 5:16 am

Re: mod_rewrite

Post by someberry »

Thanks, the below works great :)

Code: Select all

RewriteRule ^(?!plugin|Public|template).*?     index.php [L]
Post Reply