2015年9月12日 星期六

WordPress sitemap Apache .htaccess Rewrite 設定

WordPress sitemap Apache .htaccess Rewrite 設定

簡述


LNAMP LAMP 架構下 WordPress MU WordPress Nework 網誌網路使用 Yoast SEO sitemap XML網站地圖 時 Apache 後台的 .htaccess rewrite 規則定義檔的設定方式, Nginx 不使用此檔
檔案位置: /網站根目錄/.htaccess
包含 WordPress rewrite 規則、Yoast SEO 外掛中 sitemap 的 rewrite 規則, 並已考慮 WordPress MU 子目錄架構的狀況。內容定義如下:
# BEGIN WordPress

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# Yoast SEO sitemap rewrite rule for WordPress - start (by rex)
RewriteRule ^([^/]+/)*sitemap_index.xml$ /$1index.php?sitemap=1 [L]
RewriteRule ^([^/]+/)*locations.kml$ /$1index.php?sitemap=wpseo_local_kml [L]
RewriteRule ^([^/]+/)*geo_sitemap.xml$ /$1index.php?sitemap=geo [L]
RewriteRule ^([^/]+/)*([^/]+?)-sitemap([0-9]+)?.xml$ /$1index.php?sitemap=$2&sitemap_n=$3 [L]
RewriteRule ^([^/]+/)*([a-z]+)?-?sitemap.xsl$ /$1index.php?xsl=$2 [L]
# Yoast SEO sitemap rewrite rule for WordPress - end

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]

</IfModule>

# END WordPress

沒有留言:

張貼留言