Create Cookie Free Domain for WordPress

  • Avinash
  • 35
  • Jul 13, 2011
  • Tutorial

Its better to serve the static contents from separate cookie free domain. Which speed up your website. This is because browser will consider both as a separate domain.

The simplest way to create a cookie free domain in create a sub domain. By default what ever cookies created on main domain will be shared on sub domain also.

But in wordpress we can define that only for which domain it should store the cookies. So it will not get shared on subdomain.

Here are the steps for that:

First create a subdoamin. like,, i generally use

Now point this domain to the wp-content directory of the wordpress.

Aftre doing this you need to edit the wp-config.php file which is located at the root of the wordpress.

You need to add below code in your wp-config.php file.

define("WP_CONTENT_URL", ""); define("COOKIE_DOMAIN", "");
define("WP_CONTENT_URL", "");
define("COOKIE_DOMAIN", "");

Note: Please make sure that you have used “bloginfo(‘template_directory’)” to load your static content in theme files.

Please check here for more details about cookie free sub domain.

Related Posts

Written by Avinash

Avinash Zala is leading various projects which deals with the various technology involved with the web. A combination of perfect technical and management skills. Avinash would like to chat with you and convert your imagination into the working system. You can get in touch with him on Facebook and Twitter.

View all posts by:

  • Sanjay

    Thanks it helps me.
    But can you Please explain little bit more?

    It works for me but i dont know how it works?

  • ads

    very helpful for me.

  • Pingback: My Stream » 10 Quick Tips: Optimizing & Speeding Up Your WordPress Site

  • Pedro


    have this any implication with affiliate links??

    If someone click an affiliate url like from, will the cookies still remain in their computers???


  • Praveen Gowda I V

    Hello, but my blog has been already there for a long time
    Noe how can I switch to CDN

  • Pingback: 10 Quick Tips: Optimizing & Speeding Up Your WordPress Site | Graphfucker

  • Pingback: 10 Quick Tips: Optimizing Your WordPress Site | Wptuts+

  • Ahmad Awais

    Great article !
    Tell me my other plugins like w3cache will be affected or not?

  • Pradeep Kumar Jangid

    Dear Xpert,

    I use this code in my htaccess file for make cookies free subdomain. but i think it is not working bcz in yslow cookie free domain status showing same before used this code.

    I want to make a cookie free subdomain for my site. help me if possible.

  • Pingback: 10 ??????? ?? ????????? ?????? ????? ?? WordPress | Wordpresso

  • Pingback: Wordpress Notes |

  • Ayan


    I have a question –
    Why your own STATIC sub-domain ( not showing as ‘cookie-free-domain’ ?

    Same problem with mine also….

  • Pingback: Disable Cookies using .htaccess file | Expert PHP Developer

  • Muhammad

    Should i have anything when i open

    i got blank page anyways, i don’t get it!

    • Avinash

      no it’s not required to have something on that sub domain as far as it has you assets. Look at mine

  • KD Gates

    Hello, I have searched and searched the website for an answer on how to configure a cookie free domain for Word Press and unfortunately, I keep getting the same thing, a repeat of what Yahoo says to do. In your article, you explain how to set up a cookie free domain but you do not explain how to exactly point the static domain to the wp-content directory. Also, how would I make sure that I have used “bloginfo”? One last thing, where should the “static” folder be located? I think that for developers it is easy to put a few steps and leave it but for those of us who are not developers, we need a bit more help (exact steps). Thanks.

    • Avinash

      Here are your answers:

      1) Process of creating a Domain or Sub domain is totally varies from host to host. May be I will need separate article which shows this process with major hosting provider.
      2) Reg bloginfo: you just need to make sure your theme uses that function to load the static content like CSS, JS and Images.
      3) Reg static folder point: Its not required to have static folder if you are creating (varies host to host some may require), but for wordpress what you need to do is point your subdomain to wp-content directory.

      Hope this helps.

      • KD Gates

        Thank you for your help. Nothing that I am doing is working for me. I will continue to research to see what I am doing wrong. I have changed everything and WordPress is not picking up the “static” files.

  • Mike The spike

    Thank you that’s great

  • Pingback: 10 Quick Tips: Optimizing & Speeding Up Your WordPress Site

  • Pingback: Cookie Free Domain Doesn't work - feed99

  • Zefri Kurnia

    Hello, your way is good to speed up the wordpress website..
    but you’re not realize when you upload the files, your files will go to your static URL..
    for example when you upload image.jpg, so the file will go to without the permission..
    I was move the files inside wp-content to my static URL, but when I upload the file, I get the file blank (not uploaded)

  • Javier

    We can download your PHP files located in wp-content, because they are “static”. Is this suppossed to work like this?

  • Chirag Vora

    I think clubbing up all possible CSS, JS files and using a CDN will be more useful for speed optimisation than bothering about a cookie free domain.

  • cleansites

    This is working great. I get a great results when I add the The only problem is I think the css is somewhere else and the page loads without the css. Any idea how I can fix this or what could be causing it?


  • deprito

    where i must place “bloginfo(‘template_directory’)?

  • Hawaii Photographer

    Hello Im interested in fixing this issue on my html5 website. Since my site is a non wordpress site will it work for me.

    • Avinash

      Yes, this tip has nothing to do with WordPress, it will work with your HTML site as well.

  • Kevin Allen

    hi avinash, I didn’t get it to work. what am i doing wrong? do i still need to do something on htaccess for it to work?

  • al3abmizo

    Nice solution indeed. applied it to and it works :) thank you

  • Anderson

    Hey man! This stuff still working?
    If yes, where do I put the “bloginfo(‘template_directory’)”???

  • soniya

    This is great stuff it will be working for me also.

  • Floria Alex

    Hi, can you please highlight the using of “bloginfo(‘template_directory’)”. I have no idea about it. Rest of work was easy to configure but i do not know how to check it or configure it.

  • Devender Poonia

    it no working for our website please help.