Yuschick Yuschick - 1 year ago 69
Apache Configuration Question

htaccess - Redirect All but Sub-Directory (Ember js)

I am running my main website with Ember and because of that have my htaccess file set up to redirect all requests to my index page for routing.

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(.*) /index.html [NC,L]

However, I have since added a sub-directory called
that is also running on Ember. Any request made to
I want to have redirect to
again, for proper routing.

Currently, when I access
the page runs. But if I try going directly to
I am redirected to my main domain's 404 page and not to the correct
route. I need this
directory to function as a standalone site - accessing its own CSS, Js, and images without conflicting with the main domain's Ember router.

How can I configure my .htaccess file to handle this?

Answer Source

You can have a separate rule for handling /horror/:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/horror/index\.html$ [NC]
RewriteRule ^horror(/.*)?$ horror/index.html [L,NC]    

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.html [L]