问题
I'm trying to redirect my subdomain to a flder. I think I have the .htaccess code from another post here. Something like:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^clients\.example\.com$
RewriteRule ^ http://example.com/clients/root/app%{REQUEST_URI} [L,P]
What DNS settings should I set up for the clients. subdomain to tie it in with the .htaccess.
回答1:
You need to create a CNAME to point clients.example.com
to the same server as example.com
. Then you need to make sure your webserver is setup to serve the clients.example.com
in the same root as example.com
.
Of, you can simply setup clients.example.com
's vhost to point to the /clients/root/app/
folder instead. There's a directive called DocumentRoot
that you'd use to point a vhost to a where it's root folder is.
In the case of the first instance, where both the main domain and subdomain point to the same root, you don't need to use the P
flag:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^clients\.example\.com$
RewriteRule ^ /clients/root/app%{REQUEST_URI} [L]
Is good enough and circumvents the need to go through mod_proxy.
来源:https://stackoverflow.com/questions/18874085/dns-htaccess-files-to-redirect-subdomain-to-specific-folder