<p>What is the best way to transparently rewrite a URL over an SSL connection with Apache 2.2?</p>

<p>Apache 2 does not natively support multiple name-based virtual hosts for an SSL connection and I have heard that mod_rewrite can help with this. I would like to do something like this:</p>

<p>I have set up the server so that the sites can be accessed by</p>

<p><a href="https://secure.example.com/dbadmin" rel="nofollow noreferrer">https://secure.example.com/dbadmin</a></p>

<p>but I would like to have this as <a href="https://dbadmin.example.com" rel="nofollow noreferrer">https://dbadmin.example.com</a></p>

<p>How do I set it up so that the Rewrite rule will rewrite dbadmin.example.com to secure.example.com/dbadmin, but without displaying the rewrite on the client's address bar (i.e. the client will still just see dbadmin.example.com), all over https?</p>

[{'answer_id': 8389, 'author': 'UnkwnTech', 'author_id': 115, 'author_profile': 'https://Stackoverflow.com/users/115', 'pm_score': 0, 'selected': False, 'text': '<p>There is apaches mod_rewrite, or you could setup apache to direct <a href="https://dbadmin.example.com" rel="nofollow noreferrer">https://dbadmin.example.com</a> to path/to/example.com/dbadmin on the server</p>\n\n<pre><code>&lt;VirtualHost *&gt;\nServerName subdomain.domain.com\nDocumentRoot /home/httpd/htdocs/subdomain/\n&lt;/VirtualHost&gt;\n</code></pre>\n'}, {'answer_id': 8414, 'author': 'Terry G Lorber', 'author_id': 809, 'author_profile': 'https://Stackoverflow.com/users/809', 'pm_score': 2, 'selected': False, 'text': '<p>Unless your SSL certificate is the "wildcard" or multi-site kind, then I don\'t think this will work.  The rewrite will display in the browser and the name in the address bar must be valid against the certificate, or your users will see a security error (which they can always accept and continue, but that doesn\'t sound like what you\'d like).</p>\n\n<p>More <a href="http://httpd.apache.org/docs/2.0/ssl/ssl_faq.html#vhosts" rel="nofollow noreferrer">here</a>.</p>\n'}, {'answer_id': 12069, 'author': 'T Percival', 'author_id': 954, 'author_profile': 'https://Stackoverflow.com/users/954', 'pm_score': 3, 'selected': True, 'text': '<p>Configure a single VirtualHost to serve both secure.example.com and dbadmin.example.com (making it the only *:443 VirtualHost achieves this). You can then use <a href="http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html" rel="nofollow noreferrer">mod_rewrite</a> to adjust the URI for requests to dbadmin.example.com:</p>\n\n<pre><code>&lt;VirtualHost *:443&gt;\n    ServerName secure.example.com\n    ServerAlias dbadmin.example.com\n\n    RewriteEngine on\n    RewriteCond %{SERVER_NAME} dbadmin.example.com\n    RewriteRule !/dbadmin(.*)$ /dbadmin$1\n&lt;/VirtualHost&gt;\n</code></pre>\n\n<p>Your SSL certificate will need to be valid for both secure.example.com and dbadmin.example.com. It can be a wildcard certificate as mentioned by Terry Lorber, or you can use the <a href="http://wiki.cacert.org/wiki/VhostTaskForce#A1.Way.3ASubjectAltNameOnly" rel="nofollow noreferrer">subjectAltName</a> field to add additional host names.</p>\n\n<p>If you\'re having trouble, first set it up on <code>&lt;VirtualHost *&gt;</code> and check that it works without SSL. The SSL connection and certificate is a separate layer of complexity that you can set up after the URI rewriting is working.</p>\n'}]
['https://Stackoverflow.com/questions/8355', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/277/']