Subdomain redirection to external subdomain
Subdomain redirection to external subdomain - If a page has internal and external outgoing links to redirecting URLs, it’s returning 3xx (301, 302, etc.) HTTP status codes standing for redirection. This issue means that the page does not exist on a permanent or temporary basis. It appears on most of the popular web browsers, usually caused by a misconfigured website. However, there are some steps you can take to ensure the issue isn’t on your side. You can find more details about redirecting URLs by reading the Google Search Central overview. In this article, we’ll go over how you can fix the Subdomain redirection to external subdomain error on your web browser. Problem :
Solution :
We hope that this article has helped you resolve the redirects, subdomain, cname error in your web browsers. Enjoy browsing the internet uninterrupted!
I need to create a redirection from my own subdomain to an external subdomain, like subdomain.domain.com -> subdomain.external.com. So if anyone try to enter in my subdomain, it redirects automatically to subdomain.external.com.
Thanks all.
EDIT:
I tried via DNS in cPanel/WHM with CNAME and in .htaccess with:
<IfModule mod_rewrite.c>
RewriteEngine On
SetEnv HTTP_MOD_REWRITE On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %REQUEST_FILENAME !-f
RewriteCond %REQUEST_FILENAME !-d
RewriteRule . /index.php [L]
RewriteCond %HTTP_HOST ^subdomain.domain.com$ [NC]
RewriteRule ^(.*)$ https://subdomain.external.com/$1 [R=301,NC,L,QSA]
</IfModule>
But nothing works :/
The rules are applied in order, so it would not find a corresponding file and send you to /index.php
<IfModule mod_rewrite.c>
RewriteEngine On
SetEnv HTTP_MOD_REWRITE On
RewriteBase /
# First test for the redirect
RewriteCond %HTTP_HOST ^subdomain.domain.com$ [NC]
RewriteRule ^(.*)$ https://subdomain.external.com/$1 [R=301,NC,L,QSA]
RewriteRule ^index.php$ - [L]
RewriteCond %REQUEST_FILENAME !-f
RewriteCond %REQUEST_FILENAME !-d
RewriteRule . /index.php [L]
</IfModule>
The [L], which you can rewrite [last], means that rewrite rules coming after that line are ignored.
Comments
Post a Comment