0

How do I configure Apache to rewrite an http request for a subdomain to an https request for the correct directory?

For example, I have the following VirtualHost configuration:

virtualhost with rewrite

However, this turns http://redmine...us into https://redmine...us/redmine.

Also, changing

RewriteRule ^(.*)$ https://%{HTTP_HOST}/redmine [R] to

RewriteRule ^(.*)$ https://%{HTTP_HOST} [R]

seems to simply redirect the HTTP request to HTTP://...us, which is currently the default /var/www/index.html page.

Any suggestions?

1

1 Answer 1

1

Try this:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

http://www.cyberciti.biz/tips/howto-apache-force-https-secure-connections.html

1
  • The rewrite did not work, but I used a redirect like in the link you provided that is redirecting all http://redmine.example.us requests to https://redmine.example.us at the appropriate directory, and I added a virtualhost config in my default-ssl file that references ServerName redmine.example.us to the DocumentRoot /var/www/redmine. However, I am having a new issue: serverfault.com/questions/447600/… Nov 11, 2012 at 16:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .