How to Setup nginx for Yoast, SEO Framework, All In One SEO

For Yoast SEO

Basic Code

# Rewrites for Yoast SEO XML Sitemap
 rewrite ^/sitemap_index.xml$ /index.php?sitemap=1 last;
 rewrite ^/([^/]+?)-sitemap([0-9]+)?.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;

Expanded Code

#Yoast SEO Sitemaps
location ~ ([^/]*)sitemap(.*).x(m|s)l$ {
## this rewrites sitemap.xml to /sitemap_index.xml
rewrite ^/sitemap.xml$ /sitemap_index.xml permanent;
## this makes the XML sitemaps work
rewrite ^/([a-z]+)?-?sitemap.xsl$ /index.php?xsl=$1 last;
rewrite ^/sitemap_index.xml$ /index.php?sitemap=1 last;
rewrite ^/([^/]+?)-sitemap([0-9]+)?.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
## The following lines are optional for the premium extensions
## News SEO
rewrite ^/news-sitemap.xml$ /index.php?sitemap=wpseo_news last;
## Local SEO
rewrite ^/locations.kml$ /index.php?sitemap=wpseo_local_kml last;
rewrite ^/geo-sitemap.xml$ /index.php?sitemap=wpseo_local last;
## Video SEO
rewrite ^/video-sitemap.xsl$ /index.php?xsl=video last;
}

All in One SEO

.htaccess

#All in one SEO sitemap.xml

#RewriteEngine On
#RewriteBase /
RewriteRule ^sitemap.xml$ /index.php?aiosp_sitemap_path=root [L]
RewriteRule ^sitemap_(.+)_(\d+).xml$ /index.php?aiosp_sitemap_path=$1&aiosp_sitemap_page=$2 [L]
RewriteRule ^sitemap_(.+).xml$ /index.php?aiosp_sitemap_path=$1 [L]

nginx

#All in one SEO sitemap.xml

#RewriteEngine On
#RewriteBase /
RewriteRule ^sitemap.xml$ /index.php?aiosp_sitemap_path=root [L]
RewriteRule ^sitemap_(.+)_(\d+).xml$ /index.php?aiosp_sitemap_path=$1&aiosp_sitemap_page=$2 [L]
RewriteRule ^sitemap_(.+).xml$ /index.php?aiosp_sitemap_path=$1 [L]

SEO Framework

rewrite ^/sitemap\.xml$ /index.php?the_seo_framework_sitemap=xml last;
rewrite ^/sitemap\.xsl$ /index.php?the_seo_framework_sitemap=xsl last;

Σχετικά άρθρα