I'm trying to make a nested folder of a subdomain subfolder the web root in order for a test application to work properly.
My current attempt using .htaccess:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^test.example.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.test.example.com
RewriteCond %{REQUEST_URI} !myapp/views/
RewriteRule (.*) /myapp/views/$1 [L]
Preferred outcome: when I visit test.example.com/myapp/
it should show the content in the views folder. Is there a possibility of this working? I know this would work on the root domain but I need it to be working on the subdomain subfolder.
CodePudding user response:
You need to remove check for HTTP_HOST
to allow this rule to execute for all the domains. More importantly you will need rules in site root and myapp/
sub directories.
Code in site root:
RewriteEngine On
RewriteRule !^myapp/views/ myapp/views%{REQUEST_URI} [L,NC]
Code in myapp/.htaccess
:
RewriteEngine On
RewriteRule !^views/ views%{REQUEST_URI} [L,NC]