How to stop .htaccess ReWrite rules affecting Subdomains -
i have code in .htaccess file
rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(online-shop)/?$ $1/home [l,nc] rewriterule ^(my)/?$ $1/home [l,nc] rewriterule ^(blog)/(post|tags)/([\w-]+)/?$ index.php?id=$1&type=$2&unique=$3 [l,qsa,nc] rewriterule ^(blog)/(archives)/([0-9]{4})/([0-9]{2})?$ index.php?id=$1&type=$2&year=$3&month=$4 [l,qsa,nc] rewriterule ^([\w/-]+)/?$ index.php?id=$1 [l,qsa] so following urls rewritten:
domain.com/home domain.com/index.php?id=home
however if @ subdomain (cp.domain.com) following error:
the requested url /home/user/public_html/index.php not found on server. additionally, 404 not found error encountered while trying use errordocument handle request. so subdomains looking in root directory domain should looking in directory set in control panel
as remove line of code:
rewriterule ^([\w/-]+)/?$ index.php?id=$1 [l,qsa]
the subdomains start working fine
you can try restrict last rule work main domain:
rewritecond %{http_host} ^(?:www\.)?domain\.com$ [nc] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^([\w/-]+)/?$ index.php?id=$1 [l,qsa]
Comments
Post a Comment