I have public and private projects on my webserver. I put everything what is public into the webserver root, and I have a private
folder there which I can only reach from local network (set by .htaccess in there).
I want to simply put every private projects in the private
folder and handle the requests automatically, but want the URLs look like they are served from webroot.
For example if there is private/project1
I want to use the URL http://example.com/project1 to serve that folder and don't want to change the URL.
This simple rewrite:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ private/$1
works, but when I have a private/project2
with another .htaccess
:
Options +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /project2/
<Files .*>
Order Deny,Allow
Deny From All
</Files>
# Allow asset folders through
RewriteRule ^(assets/.+) - [L]
# Protect files from being viewed
RewriteRule ^(uploads.+) - [F,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Options -Indexes
then the static content will appear, but the links are broken. What should I modify to work ?
Also if I have a private/project3
and browse to http://example.com/project3/
there is no problem, but when I browse to http://example.com/project3
(without the trailing /) the URL will be visible as http://example.com/private/project3/
in the browser. Why ? How can I avoid that ?