views:

30

answers:

1

I have a list of folders in the htdocs that I want to include in my Apache configuration file, but I don't want to include every directory that's there manually, as more may be added later.

I have 5 or so folders redirecting correctly, another redirect that does to the old index.htm in the htdoc's folder and another that does to the cherrypy web-server that I have. This is my configuration:

RewriteRule ^/static/(.*) /static/$1 [nc,l]
RewriteRule ^/brands/(.*) /brands/$1 [nc,l]
RewriteRule ^/downloads/(.*) /downloads/$1 [nc,l]
RewriteRule ^/events/(.*) /events/$1 [nc,l]
RewriteRule ^/js/(.*) /js/$1 [nc,l]
RewriteRule ^/olddesign(.*) /$1 [nc,l]
RewriteRule ^/ http://127.0.0.1:8080/$1 [proxy]

How would I go about making sure that every folder in the htdocs gets redirected, /olddesign goes to the right place and not entering a directory (for example, just like entering http://localhost/) would direct to the cherrypy web server?

Any help would be greatly appreciated.

+1  A: 

Try these rules:

RewriteRule ^/olddesign(.*) /$1 [nc,l]
RewriteCond $0 =/ [OR]
RewriteCond %{DOCUMENT_ROOT}$0 !-d
RewriteRule ^/[^/]* http://127.0.0.1:8080%{REQUEST_URI} [proxy]

The last rule will only be applied if either the requested URL path is just / or if the first path segment can not be mapped to an existing directory.

Gumbo