rewrite url so the banners get served over my cdn instead of my server

November 15, 2014 3k views


I use AdRotate ( for my banners on my blog. Right now they dont get served by my cdn when a visitors visit my site instead they get received bay my host and slow tings down. Can i use some sort of url change so instead off it look more like this: when it comes from that address my cdn handle the file.

can this be fix?

1 Answer

If your banners are all in a single directory separate from other files that you may still want to be served directly a basic rewrite like the one below should do the trick:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.*)$ [NC]
RewriteRule ^(.*)$$1 [R=301,L]
  • I have try this in my .htaccess file but it dont fix the problem.

  • Do you have rewrites enabled on your droplet? To do this you need to enable the apache module:


    And ensure that your virtualhost configuration (in /etc/apache2/sites-enabled) includes “AllowOverride All” for the directory where your .htaccess file is located.

    Once these changes are made, be sure to restart apache for them to take effect.

    service apache2 restart
  • Hi

    Yes i have the both things already.

  • If you are using the default apache configuration the file would be /etc/apache2/sites-enabled/000-default.conf, if you are running more than one site it may have a different name. In this file there should be a <Directory> section pointed to your web root. By default this will include the directive “AllowOverride None” if you see this, it will need to be changed to “AllowOverride All” to allow directives in .htaccess files to override the site configuration defaults.

  • this is what i have:

    <Directory /var/www/>
           AllowOverride All

    Order allow,deny
    Allow from all

Have another answer? Share your knowledge.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!