类似的域重定向

发布于 2025-01-21 19:12:37 字数 437 浏览 3 评论 0原文

希望某人能够帮助我了解以下内容的工作方式,以及为什么还可以的话,为什么需要完成?

我有两个领域。

  1. domain-one.co.uk-这是主要域,并拥有SSL CERT
  2. domain-One-uk.com-这是我们客户拥有的另一个域,它不安全,他们希望它重定向到第一个域。

这仅仅是在公共文件夹中的HTACCESS文件中添加301规则的情况,还是我需要对DNS设置进行任何操作?

我添加了以下内容,但似乎没有工作

RewriteCond %{HTTP_HOST} ^www\.domain\-one\-uk\.com$
RewriteRule ^$ https://www.domain-one.co.uk/? [L,R=301]

会感谢任何帮助,并教任何人都能提供的帮助。

谢谢

Hoping somebody will be able to help me to understand how the following would work as well as why it would need to be done if that's okay?

I've got two domains.

  1. domain-one.co.uk - this is the main domain and holds an SSL cert
  2. domain-one-uk.com - this is another domain our client owns, it's not secure and they want it to redirect to the first domain.

Is this simply going to be a case of adding a 301 rule in the htaccess file in the public folder or do I need to do anything with the DNS settings?

I added the following but it didn't seem to work

RewriteCond %{HTTP_HOST} ^www\.domain\-one\-uk\.com$
RewriteRule ^$ https://www.domain-one.co.uk/? [L,R=301]

Would appreciate any help and teaching anyone can provide.

Thank you

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

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

发布评论

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

评论(1

丢了幸福的猪 2025-01-28 19:12:37

如果没有现有的URL可以重定向,这只是一个域重定向,我将在Insecure Server上的.htaccess中进行基本301重定向,这将重定向到达新域的任何内容:

Redirect 301 / https://secure-domain.net/

如果Insecure Server :曾经具有在安全服务器上也可用的内容(除了协议和域外,具有相同的URL),然后您确实需要使用重写器,例如。 :

RewriteEngine On
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

在您的情况下,丢失的“重新写入”无疑导致重定向不起作用。

仅当两个域使用此htaccess使用此htaccess时,才需要检查当前域名(即。使用同一目录由同一服务器处理)。

If there is no existing URLs to redirect and this is only a domain redirect, i'd go for a basic 301 redirect in the .htaccess on the insecure server, which will redirect anything that arrives there to the new domain :

Redirect 301 / https://secure-domain.net/

If the insecure server used to have content that is also available on the secure server (with the same URLs, besides the protocol and domain), then you indeed need to use RewriteRules, eg. :

RewriteEngine On
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

In your case, the missing "RewriteEngine On" certainly caused the redirect not to work.

The RewriteCond that checks the current domain name is only needed if this htaccess is used by both domains (ie. they are handled by the same server, using the same directory).

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