I'm using mod_rewrite in a ManagedFusion settings file (similar to .htaccess) and I want to forward all incoming requests to another port on the server, except for a few folders.
So far I have this (with the folder ui, forms, clientsystem and widgets being ignored)
RewriteEngine On
RewriteCond %{REQUEST_URI} !ui$
RewriteCond %{REQUEST_URI} !forms$
RewriteCond %{REQUEST_URI} !clientsystem$
RewriteCond %{REQUEST_URI} !widgets$
RewriteRule ^/(.*) http://localhost:8050/$1 [P,L]
This works fine as long as those exception directories don't exist, however when they are created, the rewriteengine will simply trigger again and in that case it will match the rule, thereby forwarding me to the other port after all.
How could I solve this?
Another question, if I want queries like '?file=bla' to be forwarded as well, will this simply work like this?
Edit: this is what I ended up with:
RewriteCond %{QUERY_STRING} ^(.+)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond $1 !^ui
RewriteCond $1 !^forms
RewriteCond $1 !^clientsystem
RewriteCond $1 !^widgets
RewriteRule ^/?(.*) http://localhost:8050/$1?%1 [P,L,R]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond $1 !^ui
RewriteCond $1 !^forms
RewriteCond $1 !^clientsystem
RewriteCond $1 !^widgets
RewriteRule ^/?(.*) http://localhost:8050/$1 [P,R]
Some redundancy but it works.