向域的 VHOST 添加服务器别名?

发布于 2024-07-29 06:19:24 字数 151 浏览 4 评论 0原文

我有一个 VPS。 我托管了一个指向 www 文件夹的子目录的域。 该域名在主页之前工作正常。 当我开始访问其他页面时,它会显示我的服务器 [orinalname]/[subdirectory name] 。 我想我需要向域的 VHOST 添加服务器别名。 谁能告诉我该怎么做?

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??

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

横笛休吹塞上声 2024-08-05 06:19:24

你在使用阿帕奇吗?
尝试用

<VirtualHost *:80>
   DocumentRoot "/path/to/document/root"
   ServerName name1
   ServerAlias name2
 ...

Are you using Apache?
Try with

<VirtualHost *:80>
   DocumentRoot "/path/to/document/root"
   ServerName name1
   ServerAlias name2
 ...
最初的梦 2024-08-05 06:19:24

我使用代理 Apache 选项做到了这一点,就是这样:

我的 VirtualHost 是 http://dlx/ 并且我想添加一个“别名”,例如 http://dlx/drupal/

httpd.config 文件中,我添加了代理配置:

<VirtualHost 127.0.0.1>
ServerName dlx
DocumentRoot "C:/deluxe/"
<LocationMatch /drupal/>
ProxyPass               http://localhost/drupal/
ProxyPassReverse        http://localhost/drupal/
</LocationMatch>
</VirtualHost>

在我的 dlx 虚拟主机 (C:/deluxe/) 上配置 .htaccess:

    RewriteRule ^drupal/(.*)$ http://localhost/drupal/$1 [P,L]

就是这样。 它对我有用,我希望它也对你有用。

I did it using the proxy Apache option, this is it:

My VirtualHost is http://dlx/ and I want to add an "alias" like http://dlx/drupal/

In the httpd.config file I added a proxy configuration:

<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/):

    RewriteRule ^drupal/(.*)$ http://localhost/drupal/$1 [P,L]

That's it. It works for me, I hope it also works for you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文