How to set up a WordPress cookie-less domain for images? - Hack The Tech - Latest News related to Computer and Technology

Hack The Tech - Latest News related to Computer and Technology

Get Daily Latest News related to Computer and Technology and hack the world.

Sunday, June 6, 2021

How to set up a WordPress cookie-less domain for images?

I'm having issues with setting up a cookie-less domain for my images on a WordPress site. The domain I'm using is without the www. Example: mydomain.com. I know that cookies will then transfer down to the subdomains. Pingdom is telling me to use a cookie-less subdomain (and this is preferred as I don't have to connect to yet another domain). I tried two scenarios:

  1. At first I tried creating a media.mydomain.com subdomain pointing it to /wp-content/uploads, editing my database to change all references of the uploads folder to media.mydomain.com. Then I updated wp-config to set COOKIE_DOMAIN to www.mydomain.com. This didn't work. Checking the cookies (using my web developer toolbar).. they are all still on the base domain.

  2. Then I read if your base url is going to be mydomain.com without the www that you should create a new domain to host your images on. So I bought a domain like mediamydomain.com, pointed it to /wp-content/uploads and updated my database to change all the upload URLs to this one.

Even using a new domain... I am STILL getting messages from Pingdom that I need to use a cookie-less domain for my images. I even checked the Chrome network tab to check every single image is being loaded through the new domain in each scenario, and it is.

What am I doing wrong here? What is the correct way?



source https://stackoverflow.com/questions/67852741/how-to-set-up-a-wordpress-cookie-less-domain-for-images

No comments:

Post a Comment