views:

148

answers:

5

Hi, Im sure ive seen a feature in apache that can rewrite urls so you can point domain2.com at domain1.com and it rewrites everything domain1.com to domain2.com on the fly.

is there a similar thing for https?

In apache, if i go to https://mysite.com, the page itself is over https, but all images/links are http://. Is there way to auto rewrite the html so its all https://?

(its running zen cart btw)

A: 

Unless you use absolute URLs everyhwere, this should work "automagically". So you only need to check two things:

  • use relative URLs to point to resources on your own server and
  • make sure you're not using <base href="http://something"&gt;
Joachim Sauer
A: 

You can just link to /path/to/page.html instead of http://example.com/path/to/page.html. That way, if it's HTTP it'll stay HTTP, and if it's HTTPS it'll stay HTTPS.

If Zen Cart is adding the domain to all links, though, you'll need to edit the software.

ceejayoz
+3  A: 

Try this:

Using a protocol-independent absolute path:

<img src="//domain.com/img/logo.png"/>

If the browser is viewing an page in SSL through HTTPS, then it'll request that asset with the https protocol, otherwise it'll request it with HTTP.

This prevents that awful "This Page Contains Both Secure and Non-Secure Items" error message in IE, keeping all your asset requests within the same protocol.

George Stocker
A: 

The apache module you referenced is called mod_rewrite, and yes it can handle what you are asking for, although I agree with the above answers that using a protocol independent path is the best solution.

jaywon
A: 

Some solutions are listed here: http://www.sslshopper.com/article-stop-the-page-contains-secure-and-nonsecure-items-warning.html

I recommend changing all links to // or making them relative.

Robert