Go Job Hunting at the LQ Job Marketplace
Go Back > Forums > Linux Forums > Linux - Server
User Name
Linux - Server This forum is for the discussion of Linux Software used in a server related context.


  Search this Thread
Old 07-26-2010, 10:44 AM   #1
Registered: Nov 2003
Location: Lebanon
Distribution: RHEL 5/CentOS 5/Debian Lenny/(K)Ubuntu Is Dead/Mandriva 10.1
Posts: 668
Blog Entries: 7

Rep: Reputation: 31
Apache mod_rewrite to https

Hi All
I have a website with three hostnames x y and z. x is the main url and I have a valid SSL certificate for it. Basically, I have no problem if a page is accessed through http, however if an https page is requested when a users registers or when a user logs in or over a few https links I want the url to be redirected to from y and z to https://x.

Example should go to should go to

Where test.php could be any URL.

In short, any https page requested if it is not going for hostname x it should be redirected to hostname x.

Any help please ?

Old 07-26-2010, 10:53 AM   #2
Registered: Jun 2010
Posts: 361

Rep: Reputation: 59
I assume your issue is the certificate error when the page is accessed through one of the other hostnames. In this case, rewriting won't help because the error happens at SSL handshake time which ist before all other request processing in apache.

If you can get certificates for the other hostnames, too, you can install mod_gnutls which supports "server name indication", so you can use name-based virtual hosts for ssl, too.

If not, you can change your web application's logic (maybe define the primary domainname somewhere as a class constant) to always use the primary hostname when linking to a https page.
Old 07-26-2010, 11:11 AM   #3
Registered: Nov 2003
Location: Lebanon
Distribution: RHEL 5/CentOS 5/Debian Lenny/(K)Ubuntu Is Dead/Mandriva 10.1
Posts: 668
Blog Entries: 7

Original Poster
Rep: Reputation: 31
My assumption is that a redirect wont work since the symptoms you mentioned happens but a rewrite will actually rewrite all the urls in the http/php page and therefore the actual request will be initiated to the valid SSL certificate, I.e. the same way SEO URLs are rewritten you have index.php?x=10?page=login, it gets rewritten to index.php/10/login/


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
mod_rewrite to force https - password request happening first sneakyimp Linux - Software 3 01-04-2010 01:37 AM
mod_rewrite vs https riluve Linux - Software 2 09-05-2007 02:58 PM
mod_rewrite - rule to change http to https Firebar Linux - Server 10 06-05-2007 08:29 AM
How to enable Apache mod_rewrite, after apache installed without this modue jCash Linux - Newbie 1 10-24-2006 11:23 AM
Apache:mod_rewrite MadMikie Linux - Software 0 08-03-2004 08:33 AM

All times are GMT -5. The time now is 05:13 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration