Redirecting from a CDN to a primary site for direct access to a CDN domain?

I'm not quite sure how to prevent Google from indexing my CDN domain in conjunction with my primary domain name. I would like to redirect to the Primary domain via .htaccess with reverse access to the CDN domain.

Data:

  • Both domains point to the same place in the file system.
  • Both have the same robots.txt file
  • CDN Domain: cdn.example.com
  • Primary domain: example.com

Thanks.

+4
source share
2 answers

The following rewrite rules redirect any request to cdn.example.com to example.com:

RewriteEngine On RewriteCond %{HTTP:Host} =cdn.example.com RewriteRule (.*) http://example.com/$1 [R=301,L,QSA] 
+4
source

I don't know which CDN explicitly supports this type of redirection, but I assume that many of them do.

If your CDN does not work, it is best to place the index.html file with the redirect header - and this is not a bad solution at all.

 <html> <head> <meta http-equiv="refresh" content="0;url=http://primarydomain.com/" /> </head> <body> </body> </html> 

Search engines even believe that this is correct 301 .

+2
source

Source: https://habr.com/ru/post/1337348/


All Articles