I need to do a simple thing:
I have a web server, with hostname myserver.mydomain.com . On this web server, there is an index.html file in /srv/www/htdocs , and there is also one page which you call with the url http://myserver.mydomain.com/mypage or https://myserver.mydomain.com/mypage . If you type just http://myserver.mydomain.com or https://myserver.mydomain.com , then you get the index.html file in the DocumentRoot, which is working as expected. Up to here - everything’s fine.
Now, I need to make this easier for the users, so instead of typing http(s)://myserver.mydomain.com/mypage , they only need to type https://xxx.mydomain.com . I have already registered a CNAME record in the DNS named xxx , which points to myserver.mydomain.com. Logically, when I type http(s)://xxx.mydomain.com, I get to the index.html of the DocumentRoot.
In order to get to where I want to, I have put the following lines in /etc/apache2/default_server.conf :
RewriteCond %{HTTP_HOST} ^xxx.mydomain.com$ [NC]
RewriteRule ^(.*)$ https://xxx.mydomain.com/mypage$1 [R=301,L]
The results are as follows:
If you type http://xxx.mydomain.com , you get redirected correctly to https://xxx.mydomain.com/mypage and all is fine.
If you type https://xxx.mydomain.com , you don’t get redirected, and you only see the index.html as https://xxx.mydomain.com .
So, redirection works fine if you access the page via http , but it doesn’t work if you try to access via https. And what is important for me is the https access…
Has anyone done something similar? Any thoughts?
P.S. That’s an OpenSUSE 11.2 + apache2-2.2.13-2.4.1 (64bit)