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 to 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
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Blocking Google from finding your images/scripts will likely do more harm than good.
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/

Oliver2000Author Commented:
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 is indexed but not

@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.
Newly released Acronis True Image 2019

In announcing the release of the 15th Anniversary Edition of Acronis True Image 2019, the company revealed that its artificial intelligence-based anti-ransomware technology – stopped more than 200,000 ransomware attacks on 150,000 customers last year.

Oliver2000Author Commented:
Found my own solution

I just created a rule

RewriteCond %{HTTP_HOST} !^www\.domain\.com$
RewriteCond %{HTTP_HOST} !^lojas\.domain\.com$
RewriteRule ^robots\.txt$ /robots_disabled.txt [L]

which leaves google scanning the but serve a modified robot.txt if any other subdomain is called. in the robots_disabled.txt file I disallow google.

thankx anyway

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Tony McCreathTechnical SEO ConsultantCommented:
Wouldn't redirecting from the cdn urls defeat the point of having a cdn?
Oliver2000Author Commented:
@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 instead of

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.
Tony McCreathTechnical SEO ConsultantCommented:
No worries, I just picked up on "I use a cdn server with several subdomains" and then you are redirecting from those subdomains.
Oliver2000Author Commented:
Solved it!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.