Apache 将多个域重定向到其他目录

发布于 2024-09-26 13:00:55 字数 672 浏览 9 评论 0原文

我有 1 个 IP 号 83.87.163.224,我有 4 个多个域名: www.alurelingerie.nl - www.aaams​​terdam.info - www.webshopdesigners.nl - www.rtps.eu

每个域名必须重定向到我的 Apache 服务器上的子目录。我尝试使用 VirtualHost *:80 但不起作用...它没有重定向到正确的子目录... 它只重定向到第一个虚拟主机...

我想要的是: www.alurelingerie.nl >必须重定向到http://83.87.163.224/alurelingerie/www.aaams

​​terdam.info>必须重定向到http://83.87.163.224/aaams​​terdam/

www.webshopdesigners.nl>必须重定向到http://83.87.163.224/webshopdesigners/www.rtps.eu

>必须重定向到 http://83.87.163.224/rtps/

rootdir 83.87.163.224 没有子目录 >必须重定向到 http://83.87.163.224/startpagina/

有人可以帮我为我的 Apache 2.2 服务器进行设置吗... THX,抱歉我的英语不好......

I have 1 IP number 83.87.163.224 and I have 4 multiple domainnames:
www.alurelingerie.nl - www.aaamsterdam.info - www.webshopdesigners.nl - www.rtps.eu

Every domeinname must redirect to a sub dir on my Apache server. I tried to work with VirtualHost *:80 but I doesn't work... It doens't redirect to the correct subdir...
It did only redirect to the first VirtualHost...

What I want is:
www.alurelingerie.nl > must be redirected to http:// 83.87.163.224/alurelingerie/

www.aaamsterdam.info > must be redirected to http:// 83.87.163.224/aaamsterdam/

www.webshopdesigners.nl > must be redirected to http:// 83.87.163.224/webshopdesigners/

www.rtps.eu > must be redirected to http:// 83.87.163.224/rtps/

the rootdir 83.87.163.224 without a subdir > must be redirected to http:// 83.87.163.224/startpagina/

Can someone help me to set this up for my Apache 2.2 server...
THX, sorry for my bad English...

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

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

发布评论

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

评论(1

青柠芒果 2024-10-03 13:00:55

取决于“重定向”一词的确切含义。如果您指的是文档根目录,那么虚拟主机正是您所需要的:

NameVirtualHost *:80

<VirtualHost *:80>
  ServerName alurelingerie.nl
  ServerAlias www.alurelingerie.nl
  DocumentRoot /home/websites/alurelingerie.nl
</VirtualHost>

<VirtualHost *:80>
  ServerName yourseconddomain.com
  ServerAlias www.yourseconddomain.com
  DocumentRoot /home/websites/yourseconddomain.com
</VirtualHost>

等等..如果“重定向”您的意思是 HTTP 重定向(301、302),那么您应该检查 Apache 的 mod_rewrite,它非常有用简单 - 将所有域重定向到一个位置,并将所有请求放入 php 脚本,然后确定您尝试访问的域并发出 Location: /new-location 标头。

我很确定这也可以在没有 PHP 的情况下完成,但无法立即想到任何东西,也许使用 [R=301,L] 的 RewriteCond 和 RewriteRule 。

Depends on what exactly you mean by the word "redirect". If you're referring to the document root, then virtual hosts are exactly what you need:

NameVirtualHost *:80

<VirtualHost *:80>
  ServerName alurelingerie.nl
  ServerAlias www.alurelingerie.nl
  DocumentRoot /home/websites/alurelingerie.nl
</VirtualHost>

<VirtualHost *:80>
  ServerName yourseconddomain.com
  ServerAlias www.yourseconddomain.com
  DocumentRoot /home/websites/yourseconddomain.com
</VirtualHost>

And so on.. If by "redirect" you mean an HTTP redirect (301, 302) then you should check out mod_rewrite for Apache, it's quite simple - redirect all your domains to one place and place all requests onto a php script, which then determines which domain you were trying to access and issues a Location: /new-location header.

I'm quite sure this could be done without PHP too, but can't think of anything straight away, maybe RewriteCond and RewriteRule with [R=301,L].

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