Here is my directory structure:
- parent
- child-folder-1
index.php
- child-folder-2
index.php
.htaccess
I want that when I visit example.com
it should load the index.php
file from child-folder-1
directory and when I hit example.com/xyz
it should load the index.php
from child-folder-2
.
What should be the contents for my .htaccess
file?
CodePudding user response:
Assuming example.com
is the only domain that points to your account then you don't need to explicitly check for this in the rules, so you could do something like the following in the root .htaccess
file using mod_rewrite:
RewriteEngine On
RewriteRule ^$ child-folder1/index.php [L]
RewriteRule ^xyz$ child-folder2/index.php [L]
Note that if you have existing directives in your .htaccess
file then the order of the directives can be important. These rewrites would need to come after any canonical redirects.