I have multiple domains like:
www.example.com
www.myexample.com
www.this-is-an-example.com
All domains point to the main path /
on my server.
How can I point a single domain to a subdirectory on my server without showing un the URL?
I mean instead of www.myexample.com
pointing to /
on my server it should point to /myexample/
on my server.
So calling www.myexample.com
via browser should open /myexample/index.php
on my server and NOT /index.php
.
And www.myexample.com/some_path/some_file.php
should look for /myexample/some_path/some_file.php
non my server but the URL should remain www.myexample.com/some_path/some_file.php
and get changed to www.myexample.com/myexample/some_path/some_file.php
Does anybody know how to do this? I already tried to Google but without success maybe because I don't really know what to search for.
You can use this rule
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?myexample\.com$
RewriteRule !folder /folder%{REQUEST_URI} [L]
This will internally forward www.myexample.com or myexample.com (non-www) with requested uri to /folder
Try below rule too,
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ /myexample/$1 [L]