Well, specifically for the url https://secure.example.com/path/
to display content found at http://www.example.com/path/
, there's 2 things that you can do. The best thing is if the 2 domains are served from the same document root:
they are on the same host and same document root. The subdomain is literally a subfolder under the root setup with a subdomain. With help from my host we now have it resolving properly and the SSL installed.
The subdirectory might be a problem, since it may not be able to rewrite out of its own document root. For example:
- domain -> document root
- www.example.com -> /path/to/htdocs
- secure.example.com -> /path/to/htdocs/secure
If you had an .htaccess file in /path/to/htdocs/secure
to rewrite requests for https://secure.example.com/
. The problem here is you need to rewrite to the parent directory, and apache won't let you do that. If it was the other way around, you could rewrite requests for http://www.example.com/
to /secure
. Also, if the two domains had the same document root, you could also rewrite. But not if secure is a subdirectory to www's document root.
My host says that mod_proxy is installed. My Apache config shows these are installed: proxy_module (static) proxy_connect_module (static) proxy_ftp_module (static) proxy_http_module (static) proxy_ajp_module (static) proxy_balancer_module (static)
That means you can at least use the P
rewrite flag to send the request off to mod_proxy, so you can do something like this:
RewriteEngine On
RewriteRule ^path/$ http://www.example.com/path/ [L,P]
in the htaccess file in your secure.example.com's document root. That will only proxy specifically the URI /path/
, and not anything like /path/foo/bar.html
. If you want everything starting with /path/
, then you can match against it:
RewriteRule ^path/(.*)$ http://www.example.com/path/$1 [L,P]
If there are redirection issues, you may want to resort to using ProxyPass
instead:
ProxyPass / http://www.example.com/
ProxyPassReverse / http://www.example.com/
It does the same thing except it rewrites location headers so redirects also get proxied.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…