Our website would like to use cookies to store information on your computer. You may delete and block all cookies from this site, but parts of the site will not work as a result. Find out more about how we use cookies.

Login or Register

Powered by
Powered by Novacaster
Trivial, I thought.
by Bruce Ure at 12:03 26/08/05 (Forum::Technical Advice::General)
But it's not.
I've recently moved a site from plain old http://site.com/app to https://www.site.com/app and thought, "I know, I'll just stick in a redirect meta tag and then I won't even have to tell the users anything's changed".

No such luck, cos of course it would pick up the same default page and redirect to itself. Not bright.

Is there a way to do this that doesn't involve fiery hoops?


<< linux 'find' command mod_rewrite notes >>
View Comments (Threaded Mode) Printer Version
Trivial, I thought. Bruce Ure - 12:03 26/08/05
Re: Trivial, I thought. Simon - 12:51 26/08/05
You want a conditional rewrite rule in your webserver config - one that can check if the request came in via SSL (port 443), and redirect if and only if it didn't.

In Apache-speak, something like:

RewriteEngine on
RewriteRule ^/(app.*)$ https://www.site.com/$1

in the non-secure virtual host config ought to do the trick. Assuming you have separate vhost configs for the secure and insecure server, of course. If it's the same config for both, or you're using a global config and the same server's listening on both 80 and 443 then you need to add

RewriteCond %{SERVER_PORT} !=443

above the RewriteRule