- Code: Select all
httpdocs/
cake/ - A folder holding CakePHP (http://cakephp.org/)
sites/
domain1.com/
domain2.com/
etc...
The plan is to have all CSS/Images/templates/etc that are unique to each site in the sites respective folder. When someone accesses, say, 'http://domain1.com/foo/bar.jpg', it should check 'httpdocs/sites/domain1.com/foo/bar.jpg'. If this exists, serve this file. If it doesnt exist, redirect to the cake/ folder. Cakes own mod_rewrite will handle things from there.
I have the following .htaccess file in the httpdocs folder:
- Code: Select all
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond "/www/cms/httpdocs/sites/%{SERVER_NAME}/$1" -d [OR]
RewriteCond "/www/cms/httpdocs/sites/%{SERVER_NAME}/$1" -f
RewriteRule ^(.*)$ /sites/%{SERVER_NAME}/$1 [L]
RewriteRule (.*) cake/$1 [L]
</IfModule>
This all works fine, except that accessing, say, 'http://domain1.com/sites/' will bring up the FancyIndex listing of the directory contents. In this case it is obviously a list of all the sites being hosted by this CMS. This happens for all folders in /httpdocs.
Also, when I access 'http://domain1.com/foo/', and the folder '/foo/' exists, the FancyIndex header shows 'Index of /sites/domain1.com/foo', where as I would much prefer for security reasons as well as cosmetic reasons for it to show 'Index of /foo'.
I could just turn off FancyIndexing, but this still allows people to access the material of other sites where they are not supposed to. This is not really a solution.
My questions are:
1) How to stop people accessting /sites and other folders in /httpdocs. Requests to these should be sent through to /sites/SERVER_NAME/sites with everything else.
2) Fix the fancy index listing to display the 'correct' path, instead of the real path as it is now.
The second question might be solved with FancyIndex options, but as it is mod_rewrite playing havok initially, Im hoping this is the right place to ask.
Thanks