httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Luca Toscano <>
Subject Re: [users@httpd] Help with rewriterule
Date Mon, 06 Mar 2017 09:07:36 GMT
Hi Robert,

2017-03-05 21:57 GMT+01:00 Robert Moskowitz <>:

> Hello,
> This is for Apache 2.4 on Centos7.  I am migrating from Apache 2.2 on
> Centos6.
> I want to support redirecting all webmail queries to https.  for either
> queries to:
> or
> My old rules were:
> <VirtualHost *:80>
>     ServerName
>     ServerAlias webmail
>     RewriteEngine On
>         RewriteCond  %{SERVER_PORT} !^443$
>         RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
>         ExpiresDefault "access plus 10 years"
>         AddOutputFilterByType DEFLATE text/html text/plain text/xml
>     php_admin_flag session.cookie_secure "1"
> </VirtualHost>
> This SEEMED to only work for the webmail virtual host, and not others on
> this server.  When I used this rule set on the new server, it clearly was
> redirecting all web accesses to https.

Have you checked if the VirtualHost is the default one (you can use
apachectl -S to confirm)?

> So I tried to write a more restrictive rule, trying to follow instructions
> from
> It would seem the rule:
>         RewriteRule ^.*webmail https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
> Should work, but the test site I tried:
> Did not show this did the rewrite to https.

So from

"RewriteRule Pattern Substitution [flags]"
"In VirtualHost context, The Pattern will initially be matched against the
part of the URL after the hostname and port, and before the query string
(e.g. "/app1/index.html"). This is the (%-decoded) URL-path."

If I got it correctly you are trying to match the hostname in the Pattern,
that shouldn't work in Vhost context.

Also how to direct to
> or might
help you (and in my opinion they are way more maintainable than rewrite

Hope that helps!


View raw message