apache 向域的 VHOST 添加服务器别名?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1182271/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
add a server alias to the domain's VHOST?
提问by Arc
I have a VPS. I hosted a domain ipointing to a sub directory of the www folder. The domain works fine till the home page. The moment I start going to other pages its shows my servers [orginalname]/[subdirectory name] . I think I need to add a server alias to the domain's VHOST. Can anyone tell me how to do that??
我有一个 VPS。我托管了一个指向 www 文件夹子目录的域。域工作正常,直到主页。当我开始访问其他页面时,它会显示我的服务器 [原始名称]/[子目录名称]。我想我需要向域的 VHOST 添加服务器别名。谁能告诉我怎么做??
回答by rlovtang
Are you using Apache? Try with
你在用阿帕奇吗?试试
<VirtualHost *:80>
DocumentRoot "/path/to/document/root"
ServerName name1
ServerAlias name2
...
回答by Mescalito2
I did it using the proxy Apache option, this is it:
我使用代理Apache选项做到了,就是这样:
My VirtualHost is http://dlx/and I want to add an "alias" like http://dlx/drupal/
我的 VirtualHost 是http://dlx/,我想添加一个“别名”,例如http://dlx/drupal/
In the httpd.configfile I added a proxy configuration:
在httpd.config文件中我添加了一个代理配置:
<VirtualHost 127.0.0.1>
ServerName dlx
DocumentRoot "C:/deluxe/"
<LocationMatch /drupal/>
ProxyPass http://localhost/drupal/
ProxyPassReverse http://localhost/drupal/
</LocationMatch>
</VirtualHost>
Configure .htaccess on my dlx virtualhost (C:/deluxe/):
在我的 dlx 虚拟主机 ( C:/deluxe/)上配置 .htaccess :
RewriteRule ^drupal/(.*)$ http://localhost/drupal/ [P,L]
That's it. It works for me, I hope it also works for you.
就是这样。它对我有用,我希望它也对你有用。

