: Redirect from non-existent subdomains is correct? Search engines recorded referrals from links like this: http://subdomain1.example.com, http://subdomain2.example.com. Subdomain pages display the contents
Search engines recorded referrals from links like this: subdomain1.example.com, subdomain2.example.com. Subdomain pages display the contents of main domain pages but subdomains do not exist. CMS writes canonical link with subdomain address for subdomain page and with domain address for main domain page.
Is the correct solution for SEO to set 301 redirect from non-existent subdomains on main domain or can I just rewrite href attribute in canonical link before output for subdomain pages?
More posts by @Hamm4606531
1 Comments
Sorted by latest first Latest Oldest Best
Setting the correct canonical URL in the link element should be sufficient (although you might need to verify these "non-existent" subdomains in Google Search Console?), however, it would be preferable to set a 301 redirect which will catch users as well and prevent them linking to the wrong domain, etc.
This sort of redirect can be (should be) included as part of your canonical (www / non-www) redirect.
For example, to redirect all requests that are not for your canonical domain (eg. example.com) to your canonical domain then you can do something like the following in your server config, or .htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} !=example.com
RewriteRule .* example.com/[CO] [R=301,L]
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.