0

On a centos8 server I created a file called /etc/httpd/conf.d/rewrite.conf with these contents:

RewriteEngine on
RewriteRule (.*) https://www.othersite.com  [L,R]

If I goto http://myserver.com it gets redirected to https://www.othersite.com as expected. But, if I goto https://myserver.com its not being redirected. I just get the regular index.html. There's a valid cert installed.

Should it work like that or does apache need additional rewrite rules in the SSL virtual host definition?

1 Answers1

0

does apache need additional rewrite rules in the SSL virtual host definition?

Yes.

Your rewrite.conf file needs to be included in both places, since the vHost host overrides the main server config (where I assume you have defined the site for port 80 by the sounds of it). (Although port 80 should ideally be defined in its own vHost container.)

RewriteRule (.*) https://www.othersite.com  [L,R]

Note that this redirects all requests to the root of othersite.com - is that the intention. (Your capturing subgroup in the RewriteRule pattern suggests otherwise.)

MrWhite
  • 12,647
  • 4
  • 29
  • 41