1

I have a question regarding redirects.

We currently have set up an Apache with a wildcard certificate *.shopdomain.com and run different shops on different subdomains like shop-a.shopdomain.com, shop-b.shopdomain.com. The customer now decided, that they also want to get requests of the form www.shop-a.shopdomain.com.

What we did now is set up rewrite rules of the form:

RewriteCond %{HTTP_HOST} ^(http\:\/\/)?www\.shop-a\.shopdomain\.de$ [NC]
RewriteRule ^(.*)$ https://shop-a.shopdomain.de [R=301]

You see that we also redirect to https in this case. If you access the shop without "www", this redirect is performed by the application itself.

Problem: If I access www.shop-a.shopdomain.de for the first time, this works nice. The redirect is performed correctly and the shop works. But after that, if I use the same URL again, it seems that the browser caches this redirect. It first redirects initially to https://www.shop-a.shopdomain.de. This leads to a problem because the wild card certificate doesn't work anymore for this case. So the second rewrite that would remove the "www" cannot happen anymore, because the certificate is invalid.

Question now: Is there a ways to prevent the browser to cache the redirect to https? Or is there any other "workaround" solution? I know that the clean way would be to install certifcates for all the subdomains instead of the wildcard, but there should be a different way to handle this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.