Avatar of Oliver2000
Oliver2000Flag for Brazil

asked on 

redirect anything else as images files for subdomain?

Hi experts,

I would like to create a redirect rule for my htaccess which redirects a subdomain from for example images.domainname.com to www.domainame.com if the files which is called is anything else as an image (jpg/png/gif)

The same for a subdomain scripts (css,js)

The backgorund is that I use a cdn server with several subdomains but google start indexing my subdomains now via the cdn servers. I want to prevent google from scanning at all the subdomains since they contain only images and scripts.

thanks for your help
Apache Web ServerSearch Engine Optimization (SEO)Web Development

Avatar of undefined
Last Comment
Oliver2000
Avatar of Gary
Gary
Flag of Ireland image

Blocking Google from finding your images/scripts will likely do more harm than good.
Avatar of COBOLdinosaur
COBOLdinosaur
Flag of Canada image

If there are parts of your site that you do not want search robots to access then you should do it with robots.txt, not .htaccess.

all you need is:

User-agent: *
Disallow: /images/
Disallow: /js/
Disallow: /css/

Cd&
Avatar of Oliver2000
Oliver2000
Flag of Brazil image

ASKER

I guess both of you did not understand/read my question well.

@GaryC123: I don't want to block google from my images/scripts, I want to prevent double indexing for separate subdomains. Of course the main domain is normal indexed including all images and scripts. With other words I want that www.domain.com is indexed but not sub.domain.com

@COBOLdinosour: You cant define in robot.txt the subdomains and there for cant separate anything. if I disallow global in my robot.txt images, scripts etc. would not help because I want only prevent SUBDOMAINS from being indexed.

Since there isn't any real folder for the subdomain like I cant place a different robots.txt inside the subdomain either. The subdomains are only CNAME host entries for our cdn server.
ASKER CERTIFIED SOLUTION
Avatar of Oliver2000
Oliver2000
Flag of Brazil image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Tony McCreath
Tony McCreath
Flag of Australia image

Wouldn't redirecting from the cdn urls defeat the point of having a cdn?
Avatar of Oliver2000
Oliver2000
Flag of Brazil image

ASKER

@Tiggerito: Where did I say that the CDN redirect to anything? The subdomains are simple redirects to the cdn servers. the cdn either call the file from original www or have the file cached already. there is no redirecting for the cdns of course. this was not about the cdn or redirection but only to prevent google from scanning the new subdomains created for the cdns.

the point is that google found the subdomans and started to scan my content via this subdomains but the only reason this subdomains exist is for me to use sub.domain.com instead of 234234423server.cdn.com.

anyway solved with the above solution. now google and other search engines get served a different robots.txt on subdomains as for www and lojas.
Avatar of Tony McCreath
Tony McCreath
Flag of Australia image

No worries, I just picked up on "I use a cdn server with several subdomains" and then you are redirecting from those subdomains.
Avatar of Oliver2000
Oliver2000
Flag of Brazil image

ASKER

Solved it!
Web Development
Web Development

Web development includes all aspects of presenting content on intranets and the Internet, including delivery development, protocols, languages and standards, server software, browser clients, databases and multimedia generation.

78K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo