I have a cPanel hosting account with my primary domain pointing to public_html
. But, to make directory structure better, I add the following code to public_html/.htaccess
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/www\.MyDomain\.com [NC]
RewriteRule ^(.*)$ /MyDomain.www/$1 [NC,L]
It simply redirect all request from /public_html
to /public_html/MyDomain.www
for my primary domain.
But, the problem is when I visit http://www.MyDomain.com/
it dispays page at public_html/MyDomain.www/index.php
but with 403 HTTP code instead of 200 which is expected. Note, visiting http://www.MyDomain.com/index.php
returns page correctly with 200 HTTP code.
So, How can I fix the 403 error code?
I tried replacing the existing rewrite rule in .htaccess with this and surprisingly it worked.