You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by aparna Puram <ap...@gmail.com> on 2012/03/17 18:58:29 UTC

[users@httpd] Urgent !!! - Rewrite issue

Hello All,

I am working on a project where I have to redirect all the http requests to
https protocol. I have configured the following rewrite rules and it is
working fine.

RewriteEngine On
RewriteCond  %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ https://<dns name>$1 [L,R]


then http://<dns name> is redirecting to https://<dns name>
&     http://<localhost name> is redirecting to htps://<dns name>

However, https://<localhost name> is not being redirected to https://<dnsname>,
It is just being https://localhost

Since I have a ssl installed with the common name (CN) as the dns name.

I need the https://local host name to be redirected to https://dns name.

Kindly suggest me what needs to be done.

Thanks in advance.

Re: [users@httpd] Urgent !!! - Rewrite issue

Posted by Mathijs <ma...@gmail.com>.
All you need is an additional virtualhost that will catch all requests that
need to be redirected. See http://wiki.apache.org/httpd/CanonicalHostNames for
details on this. Note that the example there redirects from www.example.comto
example.com, but the same principles apply.

Kind regards,
Mathijs Schmittmann

On Sat, Mar 17, 2012 at 6:58 PM, aparna Puram <ap...@gmail.com> wrote:

> Hello All,
>
> I am working on a project where I have to redirect all the http requests
> to https protocol. I have configured the following rewrite rules and it is
> working fine.
>
> RewriteEngine On
> RewriteCond  %{SERVER_PORT} !^443$
> RewriteRule ^(.*)$ https://<dns name>$1 [L,R]
>
>
> then http://<dns name> is redirecting to https://<dns name>
> &     http://<localhost name> is redirecting to htps://<dns name>
>
> However, https://<localhost name> is not being redirected to https://<dnsname>,
> It is just being https://localhost
>
> Since I have a ssl installed with the common name (CN) as the dns name.
>
> I need the https://local host name to be redirected to https://dns name.
>
> Kindly suggest me what needs to be done.
>
> Thanks in advance.
>

Re: [users@httpd] Urgent !!! - Rewrite issue

Posted by aparna Puram <ap...@gmail.com>.
Hello Spliff,

The rewirtes that you have specified is performing the same.

https://<localhost> is not being redirected to https://<dnsname>

However,

http://<localhost> is redirected to https://<dns name>

Since the ssl ceritificate is installed only for the dns name, When I am
accessing https://localhost, It says ssl is installed for differncet common
name, Do you still want to access the site.

Please let me know if there is any fix to this.

On Sun, Mar 18, 2012 at 12:45 PM, SpliFF <sp...@warriorhut.org> wrote:

> I think you're saying you want:
>
> RewriteEngine On
> RewriteCond %{HTTP_HOST} ^<localhostname>$
> RewriteRule (.*) https://<dnsname>%{REQUEST_URI}
>
> As long as you are checking for https or port 443 in the rewrite condition
> you're not redirecting anywhere on HTTPS
> requests. If you want HTTPS to redirect then your condition is blocking
> that. The rules above send ALL requests to
> the dnsname using https regardless of the scheme actually requested. That
> seems to be the behaviour you're asking for.
>
> This all assumes you are using this rule in your port 80 and port 433
> virtualhosts.
>
>
>
> On 18/03/12 17:45, aparna Puram wrote:
> > Hello Spliff,
> >
> > Well actually to explain the complete scenario,
> >
> > RewriteEngine On
> > RewriteCond %{HTTPS} off
> > RewriteRule (.*) https://<dnsname>%{REQUEST_URI}
> >
> > The above rewirte is set to redirect all the http requests to https
> request.
> >
> > It is working fine when I give the http://<localhostname> it is
> rewriting to https://<dnsname>
> >
> > but when I type https://<loacalhostname> it is redirecting to https://
> <localhostname>
> >
> > I want it to be redirecting to https://<dnsname> as the ssl certificate
> CN : is the dnsname.
> >
> >
> >
> > On Sun, Mar 18, 2012 at 10:00 AM, SpliFF <spliff@warriorhut.org <mailto:
> spliff@warriorhut.org>> wrote:
> >
> >     On 18/03/12 15:02, aparna Puram wrote:
> >>     Hello Daniel/Mathijs,
> >>
> >>     There is only one virtual host.
> >>
> >>     server name is :selecvcp1.sw.ericsson.se <
> http://selecvcp1.sw.ericsson.se>
> >>     Dns name for that server is : select.ericsson.se <
> http://select.ericsson.se>
> >>
> >>     both will redirect to the same apache
> >>
> >>     when I use http:selectvcp1.sw.ericsson.se <
> http://selectvcp1.sw.ericsson.se>, I m being redirected to
> >>     https://select.ericsson.se.
> >>     However, When i type https://selectvcp1.sw.ericsson.se, I m still
> being in https://selectvcp1.sw.ericsson.se
> >>
> >>     I m not sure y. Is there any other way around?
> >>
> >
> >     If you expect https to redirect then your condition:
> >
> >     RewriteCond  %{SERVER_PORT} !^443$
> >
> >     ... is preventing that. What is the purpose of that condition if not
> to prevent https from redirecting?
> >
> >
>
>

Re: [users@httpd] Urgent !!! - Rewrite issue

Posted by SpliFF <sp...@warriorhut.org>.
I think you're saying you want:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^<localhostname>$
RewriteRule (.*) https://<dnsname>%{REQUEST_URI}

As long as you are checking for https or port 443 in the rewrite condition you're not redirecting anywhere on HTTPS
requests. If you want HTTPS to redirect then your condition is blocking that. The rules above send ALL requests to
the dnsname using https regardless of the scheme actually requested. That seems to be the behaviour you're asking for.

This all assumes you are using this rule in your port 80 and port 433 virtualhosts.



On 18/03/12 17:45, aparna Puram wrote:
> Hello Spliff,
> 
> Well actually to explain the complete scenario,
> 
> RewriteEngine On
> RewriteCond %{HTTPS} off
> RewriteRule (.*) https://<dnsname>%{REQUEST_URI}
> 
> The above rewirte is set to redirect all the http requests to https request.
> 
> It is working fine when I give the http://<localhostname> it is rewriting to https://<dnsname>
> 
> but when I type https://<loacalhostname> it is redirecting to https://<localhostname>
> 
> I want it to be redirecting to https://<dnsname> as the ssl certificate CN : is the dnsname.
> 
> 
> 
> On Sun, Mar 18, 2012 at 10:00 AM, SpliFF <spliff@warriorhut.org <ma...@warriorhut.org>> wrote:
> 
>     On 18/03/12 15:02, aparna Puram wrote:
>>     Hello Daniel/Mathijs,
>>
>>     There is only one virtual host.
>>
>>     server name is :selecvcp1.sw.ericsson.se <http://selecvcp1.sw.ericsson.se>
>>     Dns name for that server is : select.ericsson.se <http://select.ericsson.se>
>>
>>     both will redirect to the same apache
>>
>>     when I use http:selectvcp1.sw.ericsson.se <http://selectvcp1.sw.ericsson.se>, I m being redirected to
>>     https://select.ericsson.se.
>>     However, When i type https://selectvcp1.sw.ericsson.se, I m still being in https://selectvcp1.sw.ericsson.se
>>
>>     I m not sure y. Is there any other way around?
>>
> 
>     If you expect https to redirect then your condition:
> 
>     RewriteCond  %{SERVER_PORT} !^443$
> 
>     ... is preventing that. What is the purpose of that condition if not to prevent https from redirecting?
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Urgent !!! - Rewrite issue

Posted by aparna Puram <ap...@gmail.com>.
Hello Spliff,

Well actually to explain the complete scenario,

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://<dnsname>%{REQUEST_URI}

The above rewirte is set to redirect all the http requests to https request.

It is working fine when I give the http://<localhostname> it is rewriting
to https://<dnsname>

but when I type https://<loacalhostname> it is redirecting to https://
<localhostname>

I want it to be redirecting to https://<dnsname> as the ssl certificate CN
: is the dnsname.



On Sun, Mar 18, 2012 at 10:00 AM, SpliFF <sp...@warriorhut.org> wrote:

>  On 18/03/12 15:02, aparna Puram wrote:
>
> Hello Daniel/Mathijs,
>
> There is only one virtual host.
>
> server name is :selecvcp1.sw.ericsson.se
> Dns name for that server is : select.ericsson.se
>
> both will redirect to the same apache
>
> when I use http:selectvcp1.sw.ericsson.se, I m being redirected to
> https://select.ericsson.se.
> However, When i type https://selectvcp1.sw.ericsson.se, I m still being
> in https://selectvcp1.sw.ericsson.se
>
> I m not sure y. Is there any other way around?
>
>
> If you expect https to redirect then your condition:
>
> RewriteCond  %{SERVER_PORT} !^443$
>
> ... is preventing that. What is the purpose of that condition if not to
> prevent https from redirecting?
>
>

Re: [users@httpd] Urgent !!! - Rewrite issue

Posted by SpliFF <sp...@warriorhut.org>.
On 18/03/12 15:02, aparna Puram wrote:
> Hello Daniel/Mathijs,
>
> There is only one virtual host.
>
> server name is :selecvcp1.sw.ericsson.se <http://selecvcp1.sw.ericsson.se>
> Dns name for that server is : select.ericsson.se <http://select.ericsson.se>
>
> both will redirect to the same apache
>
> when I use http:selectvcp1.sw.ericsson.se <http://selectvcp1.sw.ericsson.se>, I m being redirected to
> https://select.ericsson.se.
> However, When i type https://selectvcp1.sw.ericsson.se, I m still being in https://selectvcp1.sw.ericsson.se
>
> I m not sure y. Is there any other way around?
>

If you expect https to redirect then your condition:

RewriteCond  %{SERVER_PORT} !^443$

... is preventing that. What is the purpose of that condition if not to prevent https from redirecting?


Re: [users@httpd] Urgent !!! - Rewrite issue

Posted by aparna Puram <ap...@gmail.com>.
Hello Daniel/Mathijs,

There is only one virtual host.

server name is :selecvcp1.sw.ericsson.se
Dns name for that server is : select.ericsson.se

both will redirect to the same apache

when I use http:selectvcp1.sw.ericsson.se, I m being redirected to
https://select.ericsson.se.
However, When i type https://selectvcp1.sw.ericsson.se, I m still being in
https://selectvcp1.sw.ericsson.se

I m not sure y. Is there any other way around?

When
On Sun, Mar 18, 2012 at 3:10 AM, Daniel Ruggeri <DR...@primary.net>wrote:

> On 3/17/2012 12:58 PM, aparna Puram wrote:
> > Hello All,
> >
> > I am working on a project where I have to redirect all the http
> > requests to https protocol. I have configured the following rewrite
> > rules and it is working fine.
> >
> > RewriteEngine On
> > RewriteCond  %{SERVER_PORT} !^443$
> > RewriteRule ^(.*)$ https://<dns name>$1 [L,R]
> >
> >
> > then http://<dns name> is redirecting to https://<dns name>
> > &     http://<localhost name> is redirecting to htps://<dns name>
> >
> > However, https://<localhost name> is not being redirected to
> > https://<dnsname>, It is just being https://localhost
> >
> > Since I have a ssl installed with the common name (CN) as the dns name.
> >
> > I need the https://local host name to be redirected to https://dns name.
> >
> > Kindly suggest me what needs to be done.
> >
> > Thanks in advance.
> >
> >
>
> Is this done at the server level or in vhosts? How many vhosts? I ask
> because I typically use a configuration like this:
> <VirtualHost *:80>
>   RedirectPermanent / https://somewhere.com/
> </VirtualHost>
>
> However, I typically only have one :80 vhost and one :443 vhost.
>
> If that can't work, I can't speak to why your rule isn't working... but
> you should definitely anchor with slashes like so:
> RewriteEngine On
> RewriteCond  %{SERVER_PORT} !^443$
> RewriteRule ^/(.*)$ https://<dns name>/$1 [L,R]
>
> You can also try enabling the rewrite log for more details.
>
> --
> Daniel Ruggeri
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Re: [users@httpd] Urgent !!! - Rewrite issue

Posted by Daniel Ruggeri <DR...@primary.net>.
On 3/17/2012 12:58 PM, aparna Puram wrote:
> Hello All,
>
> I am working on a project where I have to redirect all the http
> requests to https protocol. I have configured the following rewrite
> rules and it is working fine.
>
> RewriteEngine On
> RewriteCond  %{SERVER_PORT} !^443$
> RewriteRule ^(.*)$ https://<dns name>$1 [L,R]
>
>
> then http://<dns name> is redirecting to https://<dns name>
> &     http://<localhost name> is redirecting to htps://<dns name>
>
> However, https://<localhost name> is not being redirected to
> https://<dnsname>, It is just being https://localhost
>
> Since I have a ssl installed with the common name (CN) as the dns name.
>
> I need the https://local host name to be redirected to https://dns name.
>
> Kindly suggest me what needs to be done.
>
> Thanks in advance.
>
>

Is this done at the server level or in vhosts? How many vhosts? I ask
because I typically use a configuration like this:
<VirtualHost *:80>
   RedirectPermanent / https://somewhere.com/
</VirtualHost>

However, I typically only have one :80 vhost and one :443 vhost.

If that can't work, I can't speak to why your rule isn't working... but
you should definitely anchor with slashes like so:
RewriteEngine On
RewriteCond  %{SERVER_PORT} !^443$
RewriteRule ^/(.*)$ https://<dns name>/$1 [L,R]

You can also try enabling the rewrite log for more details.

-- 
Daniel Ruggeri


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org