On my server the domain “domain.com” points to “/docroot/”
I would like to rewrite all requests from “domain.com/example1” to get files and directories located in:
“/docroot/example1/web/“
So if someone requests “domain.com/example1/image.jpg” they should get the file located in “/docroot/example1/web/image.jpg”
I have already done some research and came up with this:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
RewriteCond %{REQUEST_URI} !^/web$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /example1/web/$1 [QSA]
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
RewriteRule ^(/)?$ web/ [L,QSA]
</IfModule>
The htaccess file is located in /docroot/example1/
As far as I can see this works BUT an issue arises whenever there is a directory of the same name inside of “web”, like this: /docroot/example1/web/web/
If “domain.com/example1/web/image.jpg” is requested, I would want them to get “/docroot/example1/web/web/image.jpg”.
However if the first “web”-directory already contains a file named “image.jpg” (so “/docroot/example1/web/image.jpg”) then this file is served.
Does anyone have a solution or ideas?
ferqusanga is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.