Simple rule scenario

Dec 4, 2008 at 7:46 PM
Edited Dec 4, 2008 at 7:56 PM
I'm having trouble getting some certain conditions to work, I hope you can help.

I want to redirect all requests, other than css, jpg etc.. to the root /index.php.

That I can do fine and works well so that I can have seo friendly urls, thank you!

However I also have a special directory on my server that houses client projects, eg:

What I want to happen in this case is the index.php in the /jondoe directory to be run instead of the root index.php

so for example

all point to

points to
points to

I'm guessing I need a wildcard in there for the client name part but I just can't seem to get it right.

I'd appreciate any help, here's what I've got..

#RewriteCond %{REQUEST_FILENAME}     !-f                                 
#RewriteCond %{REQUEST_FILENAME}     !-d
RewriteRule /(.*\.)(php|asp|aspx|xml|js|swf|flv|ico|jpg|png|jpeg|gif|ttf|sql|txt|htm|zip|css)
RewriteRule ^/clients/([^/]+)  /clients/$1/index.php    [I,L]                  
RewriteRule (?!^/clients) /index.php            [I,L]
Dec 4, 2008 at 9:50 PM

Did you try the test driver?

I used these rules and it seemed to work?

RewriteRule /(.*\.)(php|asp|aspx|xml|js|swf|flv|ico|jpg|png|jpeg|gif|ttf|sql|txt|htm|zip|css)

RewriteRule ^/clients/([^/]+)  /clients/$1/index.php    [I,L]

RewriteRule ^/(?!clients).*    /index.php            [I,L]

What problem are you seeing?

Dec 5, 2008 at 9:38 AM
Edited Dec 5, 2008 at 10:18 AM
Thanks for the quick reply,  I've run the testdriver app and the the rules seem to be working perfectly,:
Processing URLs...(gstm\SampleUrls.txt)

REWRITE '/about' ==> '/index.php' OK
REWRITE '/projects' ==> '/index.php' OK
REWRITE '/projects/housing' ==> '/index.php' OK
REWRITE '/clients/jondoe' ==> '/clients/jondoe/index.php' OK
REWRITE '/clients/jondoe/about' ==> '/clients/jondoe/index.php' OK
REWRITE '/clients/jondoe/contact' ==> '/clients/jondoe/index.php' OK
REWRITE '/clients/jondoe/contact/washington' ==> '/clients/jondoe/index.php' OK
REWRITE '/clients/jondoe/contact/europe' ==> '/clients/jondoe/index.php' OK
REWRITE '/clients/bobdole' ==> '/clients/bobdole/index.php' OK
REWRITE '/clients/bobdole/about' ==> '/clients/bobdole/index.php' OK
REWRITE '/clients/bobdole/contact' ==> '/clients/bobdole/index.php' OK
REWRITE '/clients/bobdole/contact/washington' ==> '/clients/bobdole/index.php' OK
REWRITE '/clients/bobdole/contact/europe' ==> '/clients/bobdole/index.php' OK
0 Errors in 13 Total Trials

However my issue is that my index.php page relies on the HTTP_X_REWRITE_URL header.

I'm running various customer sites on the 2003/IIS6 server, if the site has it's own domain it works just fine.

However when a site is in development I'll setup a virtual directory in the clients folder of our company site.

It's from here that I'm having an issue serving the correct pages, it's to do with the rewrite header not including the original (pre rewritten) url.

So when I go to:

I want to see

But I'm seeing

Which essentially means my app is 'blind' to page requests and always serves the frontpage.

Dec 5, 2008 at 11:42 AM
In the readme it tells me that you must use the [U] flag to get the HTTP_X_REWRITE_URL variable set.
Have you used that flag?
Dec 5, 2008 at 11:47 AM
OK, it's all working fine now.. forgot to add an [L] after the first (static files) rule

Just in case anyone is interested, here's the rules I am using:

RewriteLog  C:\IonicRewriter\logs\iirf.log
RewriteLogLevel 5

RewriteRule /(.*\.)(php|asp|aspx|xml|js|swf|flv|ico|jpg|png|jpeg|gif|ttf|sql|txt|htm|html|zip|css)$  - [L]
RewriteRule ^/clients/([^/]+)/([^\.*]+)  /clients/$1/index.php/$2   [U,I,L]
RewriteRule ^/(?!clients).*    /index.php            [U,I,L]

Interestingly the rules above when run on the development server (2003 Web Ed. IIS6 IIRF v1.2.15 Final) give the following result:
And on the production server (2003 Web Ed. *SP2* IIS6 IIRF v1.2.15 Final)

Thanks once again for your help, and making this possible!