前言介紹
- 這款 WordPress 外掛「WordPress MU Domain Mapping」是 2008-08-10 上架。
- 目前有 3000 個安裝啟用數。
- 上一次更新是 2017-11-28,距離現在已有 2713 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
- 外掛最低要求 WordPress 3.1 以上版本才可以安裝。
- 有 99 人給過評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
donncha | wpmuguru | automattic |
外掛標籤
multisite | wordpressmu | domain mapping |
內容簡介
這個外掛讓 WordPress MU 站點或 WordPress 3.0 網路的使用者將其部落格/網站映射到另一個域名。
它需要手動安裝,因為一個文件必須複製到 wp-content/。當升級插件時,請記得更新 domain_mapping.php 和 sunrise.php。完整的說明在安裝頁面上,並且相當容易遵循。您還應該閱讀此頁面。
超級管理員必須在 Super Admin->Domain Mapping 中配置插件。在此頁面上,您必須輸入您的服務器的 IP 或 IP 地址(逗號隔開)。這些地址僅用於文檔目的,以便用戶知道它們是什麼(以便用戶可以正確設置他們的 DNS)。它們在插件中並不起特殊作用,只是為了讓用戶看到而已。
您還可以在此頁面上定義 CNAME。它很可能是您網絡的域名。有一些限制和警告,請參閱下文。
您的用戶應該轉到工具->域名映射,其中他們可以添加或刪除域名。必須為一個域名設置為部落格的主要域名。當映射域名(如“example.com”)時,您的用戶必須在其 DNS 中創建一個指向該 IP 地址的 A 記錄。如果您的服務器使用多個 IP 地址,他們應該使用多個 A 記錄。
如果您的用戶正在映射域名的主機名(有時稱為“子域名”),例如 www.example.com 或 blog.example.com,則創建一個指向其部落格 URL(而不是 IP 地址)的 CNAME 記錄即可。
為了確保用戶在原始網絡和映射域名網絡上都已登錄,登錄頁幾乎總是會重定向回部落格的原始域名。出於安全原因,如果您允許用戶在映射域上使用其儀表板,則遠程登錄會被禁用。
超級管理員現在可以選擇允許用戶通過提供 IP(或 IP 地址列表)設置 DNS ANAME 記錄,或者只設置 CNAME,而不能兩者兼備(為最終用戶輸入 CNAME 會使 IP 的使用失效)。
有關使用 CNAME 和 ANAME 處理 DNS 的辯論很多,因此根據您的偏好和設置,兩種方法都可用。
請記住以下事項:
- 應避免指向其他 CNAME 記錄的 CNAME 記錄(RFC 1034 第 5.2.2 節),因此如果您的域名是 ANAME 到 IP 地址(或地址)的情況,只告訴最終用戶使用您選擇的域名作為其 CNAME DNS 輸入。
- 只在主要域名是 IP 地址的 ANAME 的情況下使用 CNAME 方法。這非常重要。您如何知道?檢查您的 DNS 或詢問您的主機公司。
- 讓最終用戶只使用您選擇的域名而不是 IP(或 IP 地址列表)作為其 CNAME 會使您的 WordPressMU 博客平台或 WordPress 3.0 網路更容易管理,例如購買/部署新服務器,或者添加更多使用循環式輪詢場景的服務器。您的最終用戶不需要擔心 IP 地址更改。
- 最後,要告訴最終用戶使用 ANAME IP 或 CNAME 域名是由您和您的系統部署決定的。
- 進一步閱讀:http://www.faqs.org/rfcs/rfc2219.html
- 為了本地化:將翻譯文件(即 wordpress-mu-domain-mapping-xx_XX.mo)放置在目錄 wp-content/plugins/wordpress-mu-domain-mapping/languages 中。您可能需要自己創建該目錄。
動作鉤:
現在,您可以鉤入 domain_mapping mu-plugin 的某些部分,以擴展內置功能而無需修改此插件。要做到這一點,只需在 mu-plugins 目錄中創建一個名為此插件之後的腳本。
原文外掛簡介
This plugin allows users of a WordPress MU site or WordPress 3.0 network to map their blog/site to another domain.
It requires manual installation as one file must be copied to wp-content/. When upgrading the plugin, remember to update domain_mapping.php and sunrise.php. Full instructions are on the Installation page and are quite easy to follow. You should also read this page too.
Super administrators must configure the plugin in Super Admin->Domain Mapping. You must enter the IP or IP addresses (comma deliminated) of your server on this page. The addresses are purely for documentation purposes so the user knows what they are (so users can set up their DNS correctly). They do nothing special in the plugin, they’re only printed for the user to see.
You may also define a CNAME on this page. It will most likely be the domain name of your network. See below for some restrictions and warnings.
Your users should go to Tools->Domain Mapping where they can add or delete domains. One domain must be set as the primary domain for the blog. When mapping a domain, (like ‘example.com’) your users must create an A record in their DNS pointing at that IP address. They should use multiple A records if your server uses more than one IP address.
If your user is mapping a hostname of a domain (sometimes called a “subdomain”) like www.example.com or blog.example.com it’s sufficient to create a CNAME record pointing at their blog url (NOT IP address).
The login page will almost always redirect back to the blog’s original domain for login to ensure the user is logged in on the original network as well as the domain mapped one. For security reasons remote login is disabled if you allow users to use their Dashboard on the mapped domain.
Super admins can now choose to either allow users to setup DNS ANAME records by supplying an IP (or list of IP addresses) or set a CNAME but not both (entering a CNAME for the end user voids the use of IP’s)
There is a lot of debate on the handling of DNS using CNAME and ANAME so both methods are available depending on your preference and setup.
Things to remember:
CNAME records that point to other CNAME records should be avoided (RFC 1034 section 5.2.2) so only tell your end users to use your chosen domain name as their CNAME DNS entry if your domain name is an ANAME to an IP address (or addresses)
Only use the CNAME method if your main domain is an ANAME of an IP address. This is very important. How do you know? Check your dns or ask your hosting company.
Giving your users the option to just use your chosen domain name and not an IP (or list of IP’s) to set as their CNAME will make administration of your WordPressMU blog platform or WordPress 3.0 network easier, an example of this would be purchasing/deploying a new server or indeed adding more servers to use in a round robin scenario. Your end users have no need to worry about IP address changes.
Finally, telling your end users to use an ANAME IP or CNAME domain name is up to you and how your systems are deployed.
Further Reading: http://www.faqs.org/rfcs/rfc2219.html
For localization: place translation files (ie. wordpress-mu-domain-mapping-xx_XX.mo) in the directory wp-content/plugins/wordpress-mu-domain-mapping/languages. You will probably have to create that directory yourself.
Action Hooks
You can now hook into certain parts of the domain_mapping mu-plugin to enable you to extend the features that are built in without the need to modify this plugin. To do this, just create a script within the mu-plugins dir that is called AFTER this plugin (eg, call it domain_mapping_extended.php).
dm_echo_updated_msg
This hook is for when you want to add extra messages for your end users when they update their settings, the current usage would be to remove the existing action and replace it with your own as shown within the example further down the page.
dm_handle_actions_init
Before we add our own handlers for our users wanting to update their mappings, we can use this action to maybe connect to your datacenter API ready for communication. An example would be to load an API class and connect before we send and recieve XML queries. Once again, see the example down the page. Your function can make use of the $domain variable.
dm_handle_actions_add
When an user adds a domain name to their mappings, this action can be used to perform other tasks on your server. An example would be to check the user has already set up the DNS records for the name to correctly point to your server. Your function can make use of the $domain variable.
dm_handle_actions_primary
This may or may not be commonly used in most cases but is there just in case. Your function can make use of the $domain variable.
dm_handle_actions_del
When an user deletes one of their domain mappings, this action can be used to reverse what dm_handle_actions_add has done. An example would be to remove the domain mapping from your server using your datacenter’s API. Your function can make use of the $domain variable.
dm_delete_blog_domain_mappings
If the blog is ever deleted and you make use of handle_actions, then this action will enable you to tidy up. An example would be when an user has set up multiple domain mappings and the blog is deleted, your function can remove any mess left behind. Your function can make use of the $domains array (numbered array of domains). NOTE, this will also be called if the user has no mappings, care should be taken in the case of an empty array.
EXAMPLE USAGE
$msg