
內容簡介
WP Multisite 外掛,用於維護部落格 URL 重定向。
功能
永久的 301 重定向至部落格主要網域
簡易的安裝和啟用 – 不需要存取任何檔案。
檢查網域狀態
支援 UTF-8 編碼網域
WP-Cli 命令
使用方式
設定你的 DNS。確保你的網域指向你的 WordPress 安裝。你可以透過 DNS 配置設定 A or CNAME 記錄來達成這個目的。你的網頁伺服器必須配置好接收在指定網域的請求。
在網路管理 – 網站中編輯網站,然後選擇別名網域標籤。
輸入不包含 http 或 / 的網域,並按下「新增」。
按下「檢查狀態」檢查是否成功。若有任何錯誤,你會看到一個錯誤訊息。
若你要重定向時附加 URL 路徑(例如:從 some-alias.tld/some/path 重定向至 some-real-blog.tld/some/path),請加入以下內容至你的 wp-config.php 中:
define( 'WPMU_BLOG_ALIAS_REDIRECT_WITH_PATH', true );
狀態訊息
警告:該網域符合本部落格的站台網址:此部落格使用該網域名稱作為站台網址。
錯誤:網域已被另一個網站使用:另一個部落格已經將該網域視為站台網址。請從目前正在操作的部落格或另一個部落格中移除別名。
網域不可達:你的 DNS 或網頁伺服器配置很可能有錯誤,請使用命令列中的 nslookup 或 whatsmydns.net 檢查 DNS 設定。
該網域或重定向未指向此部落格:所追蹤的所有重定向都未到達你的 WordPress 網站,而是到達其他地方。你的 DNS 或網頁伺服器配置很可能有錯誤。
WP-CLI 範例
列出網域別名
列出網站 ID 123 的別名網域
wp alias-domains list --blog_id=123
輸出所有別名為簡化版的 JSON
wp alias-domains list --format=json --compact=2
在檔案中輸出包含標題列但省略其他訊息的 CSV
wp alias-domains list --format=csv --compact > alias-list.csv
新增網域別名
wp alias-domains add --blog_id=123 --domain_alias=quux.foobar.tld
移除網域別名
移除指定的別名
wp alias-domains remove --domain_alias=quux.foobar.tld
移除網站 ID 123 的所有別名
wp alias-domains remove --blog_id=123
測試網域別名
wp alias-domains test --domain_alias=quux.foobar.tld
請前往 Github 上的原始碼連結。
外掛標籤
開發者團隊
原文外掛簡介
WP Multisite plugin to maintain URL-redirects for Blogs.
Features
Permanent 301 Redirect to blogs main domain
Painless installation and activation – no file access necessary.
Checks domain status
Supports UTF-8 Domains
WP-Cli commands
Usage
Set up your DNS. Make sure your Domain points to your WordPress installation. You can achieve this by either setting up an A- or CNAME-Record in your DNS configuration. Your webserver must be configured to handle requests on the given Domain.
Under Network Admin – Sites edit the site and select the Alias Domains Tab.
Enter the domain without http ao / and click “Add”.
Click “Check Status” to see if it worked. If something went wrong you will see an error message.
If you want to redirect with URL path appended (e.g. from some-alias.tld/some/path to some-real-blog.tld/some/path), add this to your wp-config.php:
define( 'WPMU_BLOG_ALIAS_REDIRECT_WITH_PATH', true );
Status messages
Warning: The domain matches the site URL of this blog: The Blog is using the domain name as Site URL.
Error: The domain is already used by another site: A different Blog is already using the domain as Site URL. Eiter Remove the alias from the sblog you are currently workin on, or from the other one.
The domain is unreachable: There is likely an error in your DNS or your Webserver configuration. Use nslookup from he command line or whatsmydns.net to check the DNS-Settings.
The domain or a redirect does not point to this blog: Following all redirects did not end up on your WordPress-Site, but somewhere else. There is likely an error in your DNS or your Webserver configuration.
WP-CLI Examples
Listing Domain aliases
List alias domains for blog-id 123
wp alias-domains list --blog_id=123
Output minified json of all aliases
wp alias-domains list --format=json --compact=2
Output csv including the header row but omitting other messages into file
wp alias-domains list --format=csv --compact > alias-list.csv
Add Domain Alias
wp alias-domains add --blog_id=123 --domain_alias=quux.foobar.tld
Remove Domain Alias
Remove a specific alias
wp alias-domains remove --domain_alias=quux.foobar.tld
Remove all aliases for blog 123
wp alias-domains remove --blog_id=123
Testing Domain Aliases
wp alias-domains test --domain_alias=quux.foobar.tld
Plugin PHP-API
The plugin introduces two functions allowing you to add / remove a domain aliases from inside PHP.
Add Domain alias
$result = alias_domain_add( $blog_id, 'quux.foobar.tld' );
if ( is_wp_error( $result ) ) {
// handle error
}
Remove specific Domain alias
$result = alias_domain_remove_by( 'domain_alias', 'quux.foobar.tld' );
if ( is_wp_error( $result ) ) {
// handle error
}
Remove Domain aliases for a specific blog
$result = alias_domain_remove_by( 'blog_id', 123 );
if ( is_wp_error( $result ) ) {
// handle error
}
Development
Please head over to the source code on Github.
