The Setup

My setup would be to have assets shared for several sites which have similar structures though different content. In example...

http:// localhost/site1/

http:// localhost/site2/

You will find two kinds of rewrites, Content management systems content (virtually just content that's echoed to the page) and special modules (e.g. blog software module) where I've software that gets into to more specific handling of content in the database.

Therefore the first rewrite rule for that blog makes certain that your blog module handles blog demands....

http:// localhost/site1/blog/*

http:// localhost/site2/blog/*

...while using blog module software situated at...

http:// localhost/blog/

The Content management systems rewrite rule is supposed to handle non-specific module demands...

http:// localhost/site1/*

http:// localhost/site2/my_page.html*

...while using Content management systems rewrite software situated at...

http:// localhost/rewrite.php

The Issue

Your blog module and Content management systems module rewrites are conflicting. I have tried to make the best while using following rule. Here's my code...

RewriteEngine on
RewriteCond %{REQUEST_URI} !\.js$
RewriteRule .*/blog(.+) blog$1 [QSA]
RewriteRule !.*/(admin|blog|forums)(.+)$ rewrite.php

The final rule does not really work. With this particular code basically access..

http:// localhost/site1/blog/*

http:// localhost/site2/blog/*

...any blog (or admin or forums) URL for just about any site continues to be rewritten to utilize localhost/rewrite.php.

So how do you adjust the final rule to satisfy the next conditions please...

1.) The very first directory (site1 or site2 in localhost/site1/blog) remains dynamic in order to give a third site basically want without needing to adjust the code unconditionally for the reason that regard.

2.) The blog (or admin or forums) index (e.g. blog/, forums/, admin/) are addressed by their very own modules in addition to anything within individuals sites (e.g. admin/1, admin/test.html) no matter HTTP code, 200, 404, etc.

3.) Any URL that's not within the last rule's exception list is handled by rewrite.php (no matter HTTP code, 200, 404, etc).

4.) localhost/site1/blog/ isn't handled by rewrite.php and localhost/site1/random_path isn't handled through the blog module rewrite.

I'm going to be pleased to rapidly reply with any more clarifications.

Because of an early on RewriteCond someone authored that made sense I modified it also it labored great!

Note if a person decides to make use of this code the conditions apparently only work Following the specific rewrite rules for that modules (admin, blog, forums) though Prior to the Content management systems rewrite.php rule.

I'm going to be pleased to recognition any positive critiques.

RewriteEngine on
RewriteCond %{REQUEST_URI} !\.(css|js|zip)$

RewriteRule .*/admin(.+) admin$1 [QSA]
RewriteRule .*/blog(.+) blog$1 [QSA]
RewriteRule .*/forums(.+) forums$1 [QSA]

#individual...
RewriteCond %{REQUEST_URI} !.*/admin
RewriteCond %{REQUEST_URI} !.*/blog
RewriteCond %{REQUEST_URI} !.*/forums

#condensed...
RewriteCond %{REQUEST_URI} !.*/(admin|blog|forums)

RewriteRule !\.(css|js|zip)$ rewrite.php