Need help with achieving redirection + domain masking with .htaccess. It is partially working. It works for sub–pages and sub-directories but not the domain itself.
I have two domains "redir1" and "redir2". The goal is to achieve redirection with .htaccess and masking like this:
http://redir2 —> http://redir1
http://redir2/sub.php —> http://redir1/sub.php
http://redir2/index.php —> http://redir1/index.php
And url displayed to visitor has to remain what they entered:
http://redir2
http://redir2/sub.php
http://redir2/index.php
But if they entered http://redir1
they should see http://redir1
in url.
each domain has two following files: index.php sub.php
Here is the code in .htaccess:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?redir2$ [NC]
RewriteRule ^ http://redir1%{REQUEST_URI} [L,NE,P]
It is working very well for all requests that have something after domain (sub-pages and sub-directories). For example:
http://redir2/sub.php
http://redir2/index.php
But if I type in just http://redir2/
I get a "Not found" error:
The requested URL /index.html was not found on this server.
Indeed I don't have index.html but I have index.php How to solve the issue without adding index.html?
Thanks