多个域指向同一个文件夹

发布于 2024-09-09 10:02:36 字数 436 浏览 3 评论 0原文

我目前正在运行两个网站。我可以添加我的域并将根文件夹设置为 / 而不是 /domain1.com 和 /domain2.com。这样,两个网站都会转到同一个文件夹,但它们都保留各自的域名(无重定向)。我的代码确定用户是来自domain1.com 还是domain2.com,并使用PHP 显示适当的内容。

现在,我已经切换到另一个网络托管服务商。问题是它们不允许您指定根文件夹所在的位置:因此它必须是 /domain1.com 和 /domain2.com。他们似乎也不允许访问 httpd.conf 来编辑 VirtualHosts。

我尝试使用 .htaccess 进行重定向,但问题是当我转到domain2.com 时,它直接重定向到domain1.com,并且不保留domain2.com 的主机名。

我也尝试过设置符号链接,但它似乎在做完全相同的事情。

有什么办法可以解决这个问题吗?

I am currently running two websites. I am able to add my domains and set the root folder to / instead of /domain1.com and /domain2.com. That way both websites go to the same folder, however they both maintain their domain names (no redirects). My code determines whether the user is from domain1.com or domain2.com and displays the appropriate content using PHP.

Now, I have switched to another web hoster. The problem is that they don't allow you to specify where the root folder is: so it has to be /domain1.com and /domain2.com. They also don't seem to allow access to httpd.conf to edit VirtualHosts.

I have tried using .htaccess to do a redirect, but the problem is that when I go to domain2.com, it redirects straight to domain1.com, and it doesn't keep its host name of domain2.com.

I have also tried setting up symlinks, but it seems to be doing the exact same thing.

Is there any way to solve this?

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

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

发布评论

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

评论(2

花开浅夏 2024-09-16 10:02:36

你能做一个类似于下面的重写规则吗(不要相信我的语法)?

# if domain2.com, send all requests to domain1.com
RewriteEngine on
RewriteRule ^(.*)$ ../domain1.com/index.php/$1

因此,如果有人确实访问 domain2.com,所有请求都会通过 domain1.com 上的 index.php 文件进行处理(我假设你已经在做类似的事情了)。

Can you do a rewrite rule similar to the following (don't trust my syntax)?

# if domain2.com, send all requests to domain1.com
RewriteEngine on
RewriteRule ^(.*)$ ../domain1.com/index.php/$1

So if someone does go to domain2.com, all requests are passed through the index.php file on domain1.com for processing (I presume you're doing something similar already).

流年里的时光 2024-09-16 10:02:36

您应该能够使用 ssh 设置不重定向到其他域的符号链接。我有几个 .co.uk 域使用与 .com 相同的数据,但不重定向。是什么主机啊?您应该能够做到这一点,也许可以给他们发电子邮件询问为什么会重定向。

确定 htaccess 文件中没有将domain2.com重定向到domain1.com吗?

You should be able to set up symbolic links using ssh that don't redirect to the other domain. I have several .co.uk domains that use the same data as the .com that don't redirect. What host is it? You should be able to do this, maybe email them asking why it redirects.

Sure it's not in the htaccess file to redirect the domain2.com to domain1.com?

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