在一个 wordpress 中设置多个域 [英] Set multiple domains in one wordpress
问题描述
我在这个域中有 wordpress:
I have wordpress in this domain:
http://www.Dummy.com/en
并想使用第二个域,例如:
And want to use second domain such this:
http://www.Dummy2.com
对于这个 wordpress.
for this wordpress.
如何将 Dummy2 重定向到 Dummy?
这是我发现的一些代码,但我无法理解它们:
This is some codes that I find out but I couldn't understand them:
define('WP_SITEURL', ((is_ssl() == true) ? 'https://' : 'http://').$_SERVER['HTTP_HOST']);
define('WP_HOME', ((is_ssl() == true) ? 'https://' : 'http://').$_SERVER['HTTP_HOST']);
推荐答案
最佳做法是在 Web 服务器端设置重定向,而不是在 WordPress 不支持多个域时尝试让您的网站这样做 -开箱即用.根据您选择的网络服务器设置,您有两个答案.
The best practice is to setup a redirect on a web server side rather than trying to make your website to do so when WordPress doesn't support multiple domains out-of-the-box. Depending on your chosen web server setup there are two answers for you.
1.阿帕奇
您可以在简单的 VirtualHost 中使用 RedirectPermanent 指令,阅读更多内容这里
You can use the RedirectPermanent directive with a simple VirtualHost, read more here
#Location:/etc/httpd/conf/httpd.conf
<VirtualHost *:80>
ServerName www.Dummy2.com
RedirectPermanent / http://www.Dummy.com/en
</VirtualHost>
如果只有您的 Dummy2
网站也被配置为基于 WordPress 的网站,或者,您可以将重定向规则添加到 DocumentRoot 内的 .htaccess
为 www.Dummy2.com 站点配置.
If only your Dummy2
website would be configured as a WordPress-based site too then,a ternatively, you can add a redirect rule to .htaccess
inside of your DocumentRoot configured for www.Dummy2.com site.
RewriteEngine On
RewriteRule ^(.*)$ http://www.Dummy.com/en/$1 [R=301,L]
2.IIS
确保您安装了 URL Rewrite 模块,然后简单地创建一个新的重写规则,如下所示:
Make sure that you have an URL Rewrite module installed and simply create a new rewrite rule as follows:
<rule name="Dummy2.com" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(.*)?Dummy2.com" />
</conditions>
<action type="Redirect" url="http://www.Dummy.com/en/{R:0}" />
</rule>
这篇关于在一个 wordpress 中设置多个域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!