I've set up a WordPress multi-site with a wildcard ssl for example.com to access the admin area securely. However I'm also using domain mapping to map other domains to other sites e.g. alldogs.com to alldogs.example.com.

The problem is when I'm trying to access the front end of a site from and admin for a mapped domain e.g. alldogs.com by clicking "Visit Site" the Link goes to https://alldogs.com because of the forced ssl applied to the admin area. Which produces a certificate warning since the certificate is for example.com and not alldogs.com.

How can write a mod_rewrite rule to determine if the url/link clicked on is not the main domain e.g. example.com then change the https:// to http:// so the site can be accessed via port 80 and not generate a certificate warning for that mapped domains

  • It probably would be easier (and cleaner) to write a WordPress plugin to fix the offending links. – Michael Hampton Oct 21 '12 at 14:19

You can't match on the DNS name used in mod_rewrite. It only sees the query string; when a client issues GET /foo mod_rewrite will look at /foo while applying rules.

Instead of using relative links to link into your SSL-enabled area, try using absolute links (specify the full URL).

  • You're right that mod_rewrite isn't a solution since it doesn't avoid the cert problem, but RewriteCond can check hostname, protocol, etc. – Shane Madden Oct 21 '12 at 19:31

Even if you can get the rewrite working, you would still see the warning, because the client has to connect to the server with the "wrong" SSL and send the request, and then get the redirect.

If a rewrite is not easily doable (you can check what you can use in a condition in the mod_rewrite documentation), you can easily set up a Virtual Host for the "wrong" domain that will redirect everything to the correct URL? You would still see the warning though, no way around it.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.