httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j.knowl...@mgn.co.uk
Subject Re: [users@httpd] mod_rewrite help
Date Wed, 21 May 2003 18:15:50 GMT

You could try something like:

RewriteEngine On
RewriteCond   %{HTTP_HOST}    !^www\.mydomain\.com$
RewriteRule    ^(.*)$                     https://www.mydomain.com$1 [R]

so if there was any other hostname mapping to the virtualhost you'll
redirect those too.  I don't know if you should be saying R=301 for a
permanent redirect too maybe - not sure if it actually makes any
difference.  And maybe an L to indicate it is the last redirect rule to run
:-)?

James.



|---------+---------------------------->
|         |           Michael A        |
|         |           Nachbaur         |
|         |           <mike@nachbaur.co|
|         |           m>               |
|         |                            |
|         |           21/05/2003 18:28 |
|         |           Please respond to|
|         |           users            |
|         |                            |
|---------+---------------------------->
  >------------------------------------------------------------------------------------------------------------------------------|
  |                                                                                      
                                       |
  |       To:       users@httpd.apache.org, "Beau Hebert" <bhebert@c-quential.com> 
                                             |
  |       cc:                                                                            
                                       |
  |       Subject:  Re: [users@httpd] mod_rewrite help                                   
                                       |
  >------------------------------------------------------------------------------------------------------------------------------|




I think the following might work.  You'll have to add it to your HTTPS
VirtualHost.

RewriteEngine On
RewriteCond   %{HTTP_HOST}    ^mydomain.com$
RewriteRule    ^(.*)$                     https://www.mydomain.com$1 [R]

What this does (I think, I'm no mod_rewrite expert) is perform the
RewriteRule
to redirect the browser to the full domain name only if the HTTP_HOST
request
header is mydomain.com (minus the www.).

On Wednesday 21 May 2003 08:08 am, Beau Hebert wrote:
> First, a big thanks to all out in Apacheland for helping me rewrite
> incoming http requests to https. It works like a charm. But, as usual,
> one success has led to another obstacle.
>
> As mentioned, all incoming HTTP requests are rewritten to HTTPS using
> mod_rewrite with the following code (thanks again Jurgen):
>
> RewriteEngine On
> RewriteRule ^(.*)$ https://www.mydomain.com$1
>
> As a consequence to having all requests being HTTPS I also need to have
> all incoming requests contain www (i.e.
> https://www.mydomain.com/login.php  rather than simply
> https://mydomain.com/login.php), otherwise the user receives an alert
> that the name on the Certificate doesn't match the website. This is
> because the Secure Certificate is registered to the fully qualified
> domain. So, my question: is there a way (either augmenting the code
> above or including new code) so that if someone were to type
> http://mydomnain.com/anypage.jsp, it would be rewritten to
> https://www.mydomain.com/anypage.jsp.
>
> Thanks.
> Beau
>
>
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server
Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org

--
Michael A Nachbaur <mike@nachbaur.com>


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org







********************
IMPORTANT NOTICE  This email (including any attachments) is meant only for the intended recipient.
It may also contain confidential and privileged information.  If you are not the intended
recipient, any reliance on, use, disclosure, distribution or copying of this email or attachments
is strictly prohibited. Please notify the sender immediately by email if you have received
this message by mistake and delete the email and all attachments. 

Any views or opinions in this email are solely those of the author and do not necessarily
represent those of Trinity Mirror PLC or its associated group companies (hereinafter referred
to as "TM Group"). TM Group accept no liability for the content of this email, or for the
consequences of any actions taken on the basis of the information provided, unless that information
is subsequently confirmed in writing. Although every reasonable effort is made to keep its
network free from viruses, TM Group accept no liability for any virus transmitted by this
email or any attachments and the recipient should use up-to-date virus checking software.
Email to or from this address may be subject to interception or monitoring for operational
reasons or for lawful business practices. 

Trinity Mirror PLC is the parent  company of the Trinity Mirror group of companies and is
registered in England No 82548, with its address at One Canada Square, Canary Wharf, London
E14 5AP. 
********************

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message