Jon McIntosh
Jon McIntosh

Reputation: 1263

Use subdirectory as "second" root

For a project at my company I was assigned to create a front-facing site for our product. At this point it lives under its own subdirectory /front but I'd like the files to be accessible from the root directory without messing up any of the default behavior.

Example file structure:

/foo
...file.php
/bar
...index.php
...login.php
/front
.../css
.../js
...index.html
...page.html

I want to be able to access the files under /front as if they aren't even under a subdirectory. So when I go to http://website.com/ I would be seeing /front/index.html. I've accomplished this by adding this to the .htaccess file:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^$ front/$1 [L]
    RewriteRule ^(.*) front/$1 [L]
</IfModule>

The issue is now I can't seem to access /foo or /bar.

I'd appreciate any help I could get!

Upvotes: 1

Views: 37

Answers (1)

anubhava
anubhava

Reputation: 785196

You can have it this way:

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^((?!front).*)$ front/$1 [L]
</IfModule>

Upvotes: 1

Related Questions