LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 07-21-2008, 02:49 PM   #1
alitrix
Member
 
Registered: Jun 2003
Location: Netherlands, The
Distribution: Ubuntu, Kernel 2.6.7
Posts: 169

Rep: Reputation: 30
Apache https redirect without-www to with-www


I've a little problem.

I've bought (atm it's a trial, but I will upgrade it to a normal one) SSL for my domain. The request is ment for my domein example: www.domain.com

The problem is, some people forget the www. and just type https://domain.com (or are redirected from another site with this URL).
On a normal :80 port, this shouldn't be a problem, BUT on :443 this means a SSL cerficate is send that is only ment for www.domain.com.
The browsers (FF2,3 and IE7,8) see that and show a message about the SSL isn't ment for this domain, bla bla

So, I want a RewriteCond to make it forward https://domain.com -> https://www.domain.com
After researching some links on internet I found out this isn't possible, am I correct?
Cause if someone goes to https://domain.com the SSL cert is sended and then the rewritecond starts working (because it will do a rewriterule, which is only allowed if there is a encrypted-line)

So again, my question is. Am I correct with my theory?

Greetz,

Ali

Last edited by alitrix; 07-21-2008 at 02:50 PM.
 
Old 07-21-2008, 09:48 PM   #2
born4linux
Senior Member
 
Registered: Sep 2002
Location: Philippines
Distribution: Slackware, RHEL&variants, AIX, SuSE
Posts: 1,127

Rep: Reputation: 49
try putting this in your web configuration file:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC]
RewriteRule ^.*$ https://www\.%{SERVER_NAME}%{REQUEST_URI} [L,R]
 
Old 07-22-2008, 02:21 AM   #3
alitrix
Member
 
Registered: Jun 2003
Location: Netherlands, The
Distribution: Ubuntu, Kernel 2.6.7
Posts: 169

Original Poster
Rep: Reputation: 30
This works fine, but now I'm getting a endless loop :s

This is my config:
Code:
<VirtualHost *:443>
    ServerAdmin webmaster@domain.com
    ServerName www.domain.com:443
    ServerAlias www.domain.com domain.com

    DocumentRoot "/var/www/domain.com"

    RewriteEngine on
    RewriteCond %{HTTP_HOST} !^www\.domain\.com[NC]
    RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]

        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>

    <Directory /var/www/domain.com/sslCerts>
        Deny from all
    </Directory>

        <Directory /var/www/domain.com>
                Options FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        ErrorLog /var/log/apache2/domain.com/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel info

        CustomLog /var/log/apache2/domain.com/access.log combined

        SSLEngine on

        SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL

        SSLCertificateFile /var/www/domain.com/sslCerts/www-domain-com.crt
        SSLCertificateKeyFile /var/www/domain.com/sslCerts/myserver.key

        BrowserMatch ".*MSIE.*" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0
</VirtualHost>
 
Old 07-24-2008, 06:11 AM   #4
alitrix
Member
 
Registered: Jun 2003
Location: Netherlands, The
Distribution: Ubuntu, Kernel 2.6.7
Posts: 169

Original Poster
Rep: Reputation: 30
Anyone else that can help me...?
 
  


Reply



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
for www.cafeyurt.com and www.sohbetedin.net timsah Linux User Groups (LUG) 10 02-11-2006 02:20 PM
apache: http redirect for any request going to www.foo.com/* psychobyte Linux - Software 1 04-11-2005 05:57 PM
https://www.gotomypc.com/ Mufasa General 2 11-19-2004 07:22 AM
Just bought www.helpwithlinux.net and www.helpwithwindows.com Whitehat General 15 05-08-2003 12:31 PM
IPCHAINS + www redirect to IIS ctenuta Linux - Networking 1 04-12-2001 06:03 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:20 AM.

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