You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Chris Arnold <ca...@electrichendrix.com> on 2015/01/28 22:55:09 UTC

[users@httpd] Redirect http to https

Apache 2.4.10 on SLES 12. I am trying to redirect port 80 requests to 443 so that http://share.domain.tld results in https://share.domain.tld.<https://share.domain.tld./> Here is what i have tried in the vhost file:


RewriteEngine On
#Redirect share.domain.tld port 80 requests to SSL
RewriteCond %{HTTPS} !=on
RewriteRule ^/share(.*) https://share.domain.tld/share/ [R=301,L]


I also tried:


RewriteEngine On
#Redirect share.domain.tld port 80 requests to SSL
RewriteCond %{HTTPS} !=on
RewriteRule ^/(.*) https://share.domain/share/ [R=301,L]

(This redirects every request to https://share.domain.tld/share


Any hints or pointers on making this work?

Re: [users@httpd] Redirect http to https

Posted by Daniel <df...@gmail.com>.
you can Redirect / to https://domain/share/

RedirectMatch is to use regular expressions, pcre.

Please read the different uses at:
http://httpd.apache.org/docs/current/mod/mod_alias.html

El Thu Jan 29 2015 at 13:37:15, Chris Arnold (<ca...@electrichendrix.com>)
escribió:

> Don't use pcre in redirect.
>
> For what you ask you just need a simple:
> Redirect / https://yourdomain/ in the nonssl virtual host.
>
> If you insist on using pcre with redirect for some particular reason you
> have not mentioned yet, use RedirectMatch.
>
>>    Won't that redirect all traffic? I only need to redirect http://share
> traffic to https://share.domain.tld/share. Maybe this is where, as you
> mention, to use redirectmatch?
>

Re: [users@httpd] Redirect http to https

Posted by Chris Arnold <ca...@electrichendrix.com>.
Don't use pcre in redirect.

For what you ask you just need a simple:
Redirect / https://yourdomain/ in the nonssl virtual host.

If you insist on using pcre with redirect for some particular reason you have not mentioned yet, use RedirectMatch.

Won't that redirect all traffic? I only need to redirect http://share traffic to https://share.domain.tld/share. Maybe this is where, as you mention, to use redirectmatch?

Re: [users@httpd] Redirect http to https

Posted by Daniel <df...@gmail.com>.
Don't use pcre in redirect.

For what you ask you just need a simple:
Redirect / https://yourdomain/ in the nonssl virtual host.

If you insist on using pcre with redirect for some particular reason you
have not mentioned yet, use RedirectMatch.

Regards


El jue., 29 de enero de 2015 1:06, Chris Arnold <ca...@electrichendrix.com>
escribió:

>
>  On Jan 28, 2015, at 6:31 PM, Yehuda Katz <ye...@ymkatz.net> wrote:
>
>   Make sure you put these in the correct VHOST. They need to be in the
> :80 vhost, not the :443 vhost.
>
>  I usually use the Redirect directive (
> http://httpd.apache.org/docs/2.4/mod/mod_alias.html#redirect) instead.
>
>
> Yea, I tried that, like this in the :80 vhost:
>
>  Redirect permanent ^/share(.*) https://share.domain.tld/share [R=301,L]
>
>  Then in a browser type share.domain.tld and you land on http://domain.tld
> site though the URL in the browser has https://share.domain.tld
>

Re: [users@httpd] Redirect http to https

Posted by Chris Arnold <ca...@electrichendrix.com>.
On Jan 28, 2015, at 6:31 PM, Yehuda Katz <ye...@ymkatz.net>> wrote:

Make sure you put these in the correct VHOST. They need to be in the :80 vhost, not the :443 vhost.

I usually use the Redirect directive (http://httpd.apache.org/docs/2.4/mod/mod_alias.html#redirect) instead.

Yea, I tried that, like this in the :80 vhost:

Redirect permanent ^/share(.*) https://share.domain.tld/share [R=301,L]

Then in a browser type share.domain.tld and you land on http://domain.tld site though the URL in the browser has https://share.domain.tld

Re: [users@httpd] Redirect http to https

Posted by Yehuda Katz <ye...@ymkatz.net>.
Make sure you put these in the correct VHOST. They need to be in the :80
vhost, not the :443 vhost.

I usually use the Redirect directive (
http://httpd.apache.org/docs/2.4/mod/mod_alias.html#redirect) instead.

- Y

On Wed, Jan 28, 2015 at 4:55 PM, Chris Arnold <ca...@electrichendrix.com>
wrote:

>  Apache 2.4.10 on SLES 12. I am trying to redirect port 80 requests to
> 443 so that http://share.domain.tld results in https://share.domain.tld.
> Here is what i have tried in the vhost file:
>
>
>  RewriteEngine On
> #Redirect share.domain.tld port 80 requests to SSL
> RewriteCond %{HTTPS} !=on
> RewriteRule ^/share(.*) https://share.domain.tld/share/ [R=301,L]
>
>
>  I also tried:
>
>
>  RewriteEngine On
> #Redirect share.domain.tld port 80 requests to SSL
> RewriteCond %{HTTPS} !=on
> RewriteRule ^/(.*) https://share.domain/share/ [R=301,L]
>
> (This redirects every request to https://share.domain.tld/share
>
>
>  Any hints or pointers on making this work?
>