You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by David Tkacik <dt...@healthcoachinstitute.com> on 2018/06/14 15:50:05 UTC
[users@httpd] Redirect Permanent
Hey Guys,
I’m running Apache/2.4.33 on RHEL
I have this config:
<VirtualHost *:80>
ServerName "${APACHE_HOSTNAME}"
<If "%{SERVER_PORT} != '443'">
Redirect permanent / https://${APACHE_HOSTNAME}/ <https://${apache_hostname}/>
</If>
</VirtualHost>
<VirtualHost *:443>
ServerName "${APACHE_HOSTNAME}"
</VirtualHost>
When I do CURL to that localhost on port 80 it gives me back this:
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="https://${APACHE_HOSTNAME} <https://${apache_hostname}/>/">here</a>.</p>
</body></html>
I’m wondering why apache doesn’t transform the variable ?
Because when I do it’s showing me the ServerName variable correctly transformed.
#sh apachectl -t -D DUMP_VHOSTS
VirtualHost configuration:
*:80 <Domain_name> (/etc/httpd/conf.d/proxy-settings.conf:3)
*:443 <Domain_name> (/etc/httpd/conf.d/proxy-settings.conf:12)
am I missing some module ? or configuration directive ?
I also tried adding SetEnv APACHE_HOSTNAME <Domain_name>
I have the env_module (shared) loaded.
Thanks !
Re: [users@httpd] Redirect Permanent
Posted by Frank Gingras <th...@apache.org>.
You would need to use mod_macro in this case.
On Thu, Jun 14, 2018 at 11:50 AM David Tkacik <
dtkacik@healthcoachinstitute.com> wrote:
> Hey Guys,
>
> I’m running Apache/2.4.33 on RHEL
>
> I have this config:
>
> <VirtualHost *:80>
> ServerName "${APACHE_HOSTNAME}"
> <If "%{SERVER_PORT} != '443'">
> Redirect permanent / https://${APACHE_HOSTNAME}/
> <https://$%7Bapache_hostname%7D/>
> </If>
> </VirtualHost>
>
> <VirtualHost *:443>
> ServerName "${APACHE_HOSTNAME}"
> </VirtualHost>
>
> When I do CURL to that localhost on port 80 it gives me back this:
>
> <html><head>
> <title>301 Moved Permanently</title>
> </head><body>
> <h1>Moved Permanently</h1>
> <p>The document has moved <a href="https://${APACHE_HOSTNAME}
> <https://$%7Bapache_hostname%7D>/">here</a>.</p>
> </body></html>
>
> I’m wondering why apache doesn’t transform the variable ?
>
> Because when I do it’s showing me the ServerName variable correctly
> transformed.
>
> #sh apachectl -t -D DUMP_VHOSTS
>
> VirtualHost configuration:
> *:80 <Domain_name>
> (/etc/httpd/conf.d/proxy-settings.conf:3)
> *:443 <Domain_name>
> (/etc/httpd/conf.d/proxy-settings.conf:12)
>
> am I missing some module ? or configuration directive ?
>
> I also tried adding SetEnv APACHE_HOSTNAME <Domain_name>
>
> I have the env_module (shared) loaded.
>
> Thanks !
>
>
>