Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Apache: Users

Urgent !!! - Rewrite issue

 

 

Apache users RSS feed   Index | Next | Previous | View Threaded


aparnapuram at gmail

Mar 17, 2012, 10:58 AM

Post #1 of 8 (672 views)
Permalink
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.


mathijssch at gmail

Mar 17, 2012, 11:04 AM

Post #2 of 8 (654 views)
Permalink
Re: Urgent !!! - Rewrite issue [In reply to]

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 <aparnapuram [at] gmail> 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.
>


DRuggeri at primary

Mar 17, 2012, 2:40 PM

Post #3 of 8 (644 views)
Permalink
Re: Urgent !!! - Rewrite issue [In reply to]

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 [at] httpd
For additional commands, e-mail: users-help [at] httpd


aparnapuram at gmail

Mar 17, 2012, 9:02 PM

Post #4 of 8 (649 views)
Permalink
Re: Urgent !!! - Rewrite issue [In reply to]

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 <DRuggeri [at] primary>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 [at] httpd
> For additional commands, e-mail: users-help [at] httpd
>
>


spliff at warriorhut

Mar 17, 2012, 9:30 PM

Post #5 of 8 (645 views)
Permalink
Re: Urgent !!! - Rewrite issue [In reply to]

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?


aparnapuram at gmail

Mar 17, 2012, 11:45 PM

Post #6 of 8 (647 views)
Permalink
Re: Urgent !!! - Rewrite issue [In reply to]

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 [at] warriorhut> 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?
>
>


spliff at warriorhut

Mar 18, 2012, 12:15 AM

Post #7 of 8 (642 views)
Permalink
Re: Urgent !!! - Rewrite issue [In reply to]

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 [at] warriorhut <mailto:spliff [at] warriorhut>> 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 [at] httpd
For additional commands, e-mail: users-help [at] httpd


aparnapuram at gmail

Mar 18, 2012, 1:00 AM

Post #8 of 8 (638 views)
Permalink
Re: Urgent !!! - Rewrite issue [In reply to]

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 <spliff [at] warriorhut> 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 [at] warriorhut <mailto:
> spliff [at] warriorhut>> 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?
> >
> >
>
>

Apache users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.