You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Huesser Peter <pe...@psi.ch> on 2006/09/20 21:54:01 UTC
[users@httpd] Rewrite http to https
Hello
This question was often asked before but I did not get any solution to
work:
I want to rewrite all request to
"http:virtual.server.domain/path/file.html" to
"https://virtual.server.domain/path/file.html". One of the solutions I
found is:
RewriteEngine On
RewriteCond %{HTTPS} off
Rewrite ^/path/file.html https://%{HTTP_HOST}/path/file.html
I but this in the htaccess file of the DocumentRoot of the virtual
server and also in the main httpd.conf file of the webserver. Both did
not work. So I tried the following:
RewriteEngine On
RewriteCond %{HTTPS} off
Rewrite (.*) https://%{HTTP_HOST}%{REQUEST_URI}
which should rewrite all the URLs of the specific virtual host. It did
not work either. Many people found this a good solution for the problem
therefore I guess I am still missing something. Any idea ?
Thanks' in advance for any help
Pedro
RE: [users@httpd] Rewrite http to https
Posted by Huesser Peter <pe...@psi.ch>.
>
> If you are looking for particular url, this should work:
>
> RewriteEngine on
> RewriteRule ^(.*/somepath/securefile.*) https://%{SERVER_NAME}$1 [R,L]
>
This does not work on my server. I put this in the htaccess-file of the
DocumentRoot of the virtual server and it had no effect.
Pedro
---------------------------------------------------------------------
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
Re: [users@httpd] Rewrite http to https
Posted by Darek Czarkowski <dc...@infinitesource.ca>.
On Wed, 2006-09-20 at 17:03 -0400, Ricardo Stella wrote:
>
> Huesser Peter wrote:
> >
> > Hello
> >
> > This question was often asked before but I did not get any solution to
> > work:
> >
> > I want to rewrite all request to
> > “http:virtual.server.domain/path/file.html” to
> > “https://virtual.server.domain/path/file.html”. One of the solutions I
> > found is:
> >
> > RewriteEngine On
> >
> > RewriteCond %{HTTPS} off
> >
> > Rewrite ^/path/file.html https://%{HTTP_HOST}/path/file.html
> >
> > I but this in the htaccess file of the DocumentRoot of the virtual
> > server and also in the main httpd.conf file of the webserver. Both did
> > not work. So I tried the following:
> >
> > RewriteEngine On
> >
> > RewriteCond %{HTTPS} off
> >
> > Rewrite (.*) https://%{HTTP_HOST}%{REQUEST_URI}
> >
> > which should rewrite all the URLs of the specific virtual host. It did
> > not work either. Many people found this a good solution for the
> > problem therefore I guess I am still missing something. Any idea ?
> >
> > Thanks’ in advance for any help
> >
> > Pedro
> >
> On the port 80 virtual host, I have:
>
> RewriteCond %{HTTP_HOST} !^$
> RewriteRule ^/(.*) https://I_USE_A_HARDCODED_HOSTNAME/$1 [L,R]
>
> Not sure if it's the best way, but it works for me... We don't use the
> variable instead of a hard coded name for other reasons but should work
> otherwise...
>
>
> ---------------------------------------------------------------------
> 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
If you are looking for particular url, this should work:
RewriteEngine on
RewriteRule ^(.*/somepath/securefile.*) https://%{SERVER_NAME}$1 [R,L]
--
Darek Czarkowski
Ph: 604 294 6557 (Ext. 113)
Fx: 604 294 6507
www.infinitesource.ca
darekc at infinitesource dot ca
---------------------------------------------------------------------
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
RE: [users@httpd] Rewrite http to https
Posted by Huesser Peter <pe...@psi.ch>.
> On the port 80 virtual host, I have:
>
> RewriteCond %{HTTP_HOST} !^$
> RewriteRule ^/(.*) https://I_USE_A_HARDCODED_HOSTNAME/$1 [L,R]
>
Put this in the htaccess file. Did not work.
Pedro
---------------------------------------------------------------------
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
Re: [users@httpd] Rewrite http to https
Posted by Ricardo Stella <st...@rider.edu>.
Huesser Peter wrote:
>
> Hello
>
> This question was often asked before but I did not get any solution to
> work:
>
> I want to rewrite all request to
> �http:virtual.server.domain/path/file.html� to
> �https://virtual.server.domain/path/file.html�. One of the solutions I
> found is:
>
> RewriteEngine On
>
> RewriteCond %{HTTPS} off
>
> Rewrite ^/path/file.html https://%{HTTP_HOST}/path/file.html
>
> I but this in the htaccess file of the DocumentRoot of the virtual
> server and also in the main httpd.conf file of the webserver. Both did
> not work. So I tried the following:
>
> RewriteEngine On
>
> RewriteCond %{HTTPS} off
>
> Rewrite (.*) https://%{HTTP_HOST}%{REQUEST_URI}
>
> which should rewrite all the URLs of the specific virtual host. It did
> not work either. Many people found this a good solution for the
> problem therefore I guess I am still missing something. Any idea ?
>
> Thanks� in advance for any help
>
> Pedro
>
On the port 80 virtual host, I have:
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/(.*) https://I_USE_A_HARDCODED_HOSTNAME/$1 [L,R]
Not sure if it's the best way, but it works for me... We don't use the
variable instead of a hard coded name for other reasons but should work
otherwise...
--
�(((=((===���(((===========================================
RE: [users@httpd] Rewrite http to https
Posted by Huesser Peter <pe...@psi.ch>.
> > I want to rewrite all request to
> "http:virtual.server.domain/path/file.html"
> > to "https://virtual.server.domain/path/file.html". One of
> > the solutions I found is:
>
> The simplest solution to this is as follows. If you have both an http
> and https server, then you should have a <VirtualHost> block for each
> server. Inside the <VirtualHost> block for the non-ssl server (ie,
> the one on port 80), put a normal redirect:
> Redirect /path/file.html https://virtual.server.domain/path/file.html
>
> >
> > I but this in the htaccess file of the DocumentRoot of the virtual
> server
> > and also in the main httpd.conf file of the webserver. Both did not
> work. So
> > I tried the following:
>
> Don't use htaccess files if you have access to httpd.conf.
> mod_rewrite directives must also be placed inside the <VirtualHost>
> section, or you must include
> RewriteEngine On
> RewriteOptions inherit
> inside the <VirtualHost>.
>
> If you have further problems with mod_rewrite, be sure to use the
> RewriteLog to debug.
>
Thanks. This solution works. I have to make the Redirects in the
<VirtualHost> block.
Pedro
---------------------------------------------------------------------
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
Re: [users@httpd] Rewrite http to https
Posted by Joshua Slive <jo...@slive.ca>.
On 9/20/06, Huesser Peter <pe...@psi.ch> wrote:
> This question was often asked before but I did not get any solution to work:
>
>
>
> I want to rewrite all request to "http:virtual.server.domain/path/file.html"
> to "https://virtual.server.domain/path/file.html". One of
> the solutions I found is:
The simplest solution to this is as follows. If you have both an http
and https server, then you should have a <VirtualHost> block for each
server. Inside the <VirtualHost> block for the non-ssl server (ie,
the one on port 80), put a normal redirect:
Redirect /path/file.html https://virtual.server.domain/path/file.html
>
> I but this in the htaccess file of the DocumentRoot of the virtual server
> and also in the main httpd.conf file of the webserver. Both did not work. So
> I tried the following:
Don't use htaccess files if you have access to httpd.conf.
mod_rewrite directives must also be placed inside the <VirtualHost>
section, or you must include
RewriteEngine On
RewriteOptions inherit
inside the <VirtualHost>.
If you have further problems with mod_rewrite, be sure to use the
RewriteLog to debug.
Joshua.
---------------------------------------------------------------------
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