.htaccess 重定向到特定网址的子目录

发布于 2024-11-08 10:53:31 字数 622 浏览 4 评论 0原文

我需要一些重定向指导:

我在一台主机上安装了两个 WordPress - 每个安装在一个单独的子目录中。

我能够让控制面板为每个域设置重定向,例如:

  • www.domain1.com重定向到www.domain1.com/d-one/< /code>

  • www.domain2.com 重定向到 www.domain2.com/d-two/

效果很好 - 我不太担心路径包含子目录(我想我无法隐藏它)。

但是,为了方便访问者,我想设置重定向,例如:

  • www.domain1.com/contact 重定向到 www.domain1.com/d-one/contact

  • www.domain2.com/contact 重定向到 www.domain2.com/d-two/contact

...重定向知道哪个域是哪个域。

I require some guidance with redirects please:

I have two WordPress installations on one hosting - one each in a separate sub-directory.

I was able to get the control panel to set up redirects for each domain, so that - for example:

  • www.domain1.com redirected to www.domain1.com/d-one/

and

  • www.domain2.com redirected to www.domain2.com/d-two/

Which works fine - I'm not too bothered that the path contains a subdirectory (I assume I can't hide it).

However, for convenience of the visitors, I would like to set up redirects so that for example:

  • www.domain1.com/contact redirects to www.domain1.com/d-one/contact

and

  • www.domain2.com/contact redirects to www.domain2.com/d-two/contact

... the redirect knows which domain is which.

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

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

发布评论

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

评论(1

笑着哭最痛 2024-11-15 10:53:31

看到没有人急于提供帮助:(,我在其他地方做了一些自己的挖掘(如果我不这么忙的话,我可能应该早点做一些事情)......

在用尽了所有关于此的线程之后网站,我找到了这个网站:

http://corz.org/serv/tricks/htaccess2.php< /a>

将我与此解决方案放在“一个根中的多个域”下:

#two domains served from one root..
RewriteCond %{HTTP_HOST} domain-one.com
RewriteCond %{REQUEST_URI} !^/one
RewriteRule ^(.*)$ one/$1 [L]

RewriteCond %{HTTP_HOST} domain-two.com
RewriteCond %{REQUEST_URI} !^two
RewriteRule ^(.*)$ two/$1 [L]

它还帮助我隐藏了不需要的子目录 d-one 和 d-two

Seeing as no-one was in any hurry to help :( , I did my own bit of digging elsewhere (something I probably should have done earlier if I weren't in such a flap)...

After exhausting all the threads on this site, I found this site:

http://corz.org/serv/tricks/htaccess2.php

which sorted me right up with this solution under "multiple domains in one root":

#two domains served from one root..
RewriteCond %{HTTP_HOST} domain-one.com
RewriteCond %{REQUEST_URI} !^/one
RewriteRule ^(.*)$ one/$1 [L]

RewriteCond %{HTTP_HOST} domain-two.com
RewriteCond %{REQUEST_URI} !^two
RewriteRule ^(.*)$ two/$1 [L]

and it also helped me to hide the unwanted subdirectories d-one and d-two.

Loverly jubbly!

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