Remove 3rd party plugin specific Nginx rules from wpcommon.conf
The following section in /etc/nginx/common/wpcommon.conf for Yoast's SEO plugin hurt other SEO / Sitemap plugins like https://wordpress.org/plugins/xml-sitemap-feed/ for example.
# Yoast sitemap
location ~ ([^/]*)sitemap(.*)\.x(m|s)l$ {
rewrite ^/sitemap\.xml$ /sitemap_index.xml permanent;
rewrite ^/([a-z]+)?-?sitemap\.xsl$ /index.php?xsl=$1 last;
# Rules for yoast sitemap with wp|wpsubdir|wpsubdomain
rewrite ^.*/sitemap_index\.xml$ /index.php?sitemap=1 last;
rewrite ^.*/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
# Following lines are options. Needed for WordPress seo addons
rewrite ^/news_sitemap\.xml$ /index.php?sitemap=wpseo_news last;
rewrite ^/locations\.kml$ /index.php?sitemap=wpseo_local_kml last;
rewrite ^/geo_sitemap\.xml$ /index.php?sitemap=wpseo_local last;
rewrite ^/video-sitemap\.xsl$ /index.php?xsl=video last;
access_log off;
}
My argument? It's just unfair to include rules that cripple plugin atlernatives AND Yoast's plugin works just fine without them. If not simply removed, they should at least be made optional...
I also think this should be removed, it breaks other sitemaps. In addition we should not encourage the use of such a freemium plugin where more and more functionality is been stripped.
A big +1 for that. While we're on the subject, however, can we add a declaration to "site create" that adds e-commerce provisions for proper caching in the nginx.conf file for a site? If this is already accounted for, I'm sorry for missing it. I've just noticed some odd behavior with woocommerce and ssl when it comes to caching and it would be nice to make sure carts and wishlists, etc are not being served as static content.
On Sunday, December 6, 2015, mrmad [email protected] wrote:
I also think this should be removed, it breaks other sitemaps.
— Reply to this email directly or view it on GitHub https://github.com/EasyEngine/easyengine/issues/601#issuecomment-162285730 .
hi rtcampers. hi @rahul286.
i'm just putting in my +1 here and popping in to say that i think we should really, really get rid of all the yoast stuff from the various wpcommon configs and in general, as an ee policy should avoid adding this kind of stuff to the configs.
if ee is going to support this kind of functionality at all (and i think there is a good argument for not doing so and just letting admins add these kind of configs on their own), it should be via small, tight includes that are easy to either add or not add (ee site create example.com --wp --yoast-sitemap).
it's disappointing to set up a new server with easy engine and find i immediately have to start editing files that say DO NOT MODIFY, ALL CHANGES LOST AFTER UPDATE EasyEngine (ee) at the top of them...
This thing was driving me crazy too. Why in hell is this location block included by default?
I think these rules actually belong in a site's own /var/www/example.com/conf/nginx/yoast.conf either created automatically with an option like --yoast-sitemap as @pjv suggested, or left up to admin to create manually.
Same should go for Woocommerce cookie/cache rules as @MattyLB metnions. These are plugin specific and can cause issues or unexpected behavior with other e-commerce plugins. Should be moved in an optional /var/www/example.com/conf/nginx/woo.conf file.
It should be according to these guidelines: https://codex.wordpress.org/Nginx#General_WordPress_rules
To point the specific one out:
location / {
try_files $uri $uri/ /index.php?$args;
}
Most plugins (as they should) write according to WordPress' rewrite API. The rule above simulates that flow perfectly.
Moreover, it's cleaner, maybe even faster; but, most importantly: It's future-proof and doesn't break plugins.
Indeed, even without these Yoast SEO specific rules, the Yoast sitemap will work fine. They are there just to prevent the normal WordPress rewrites from having to kick in, speeding things up a tiny fraction.
I feel the advantage of that (for Yoast sitemap users) is overshadowed by the disadvantage of those rules breaking other sitemap plugins.
Plugin specific rules should be moved to easyengine plugins like proposed on https://github.com/EasyEngine/easyengine/issues/509 for W3TC and WPSC rules.
Another +1 :-). Just spent time tracking this problem down (broken sitemap), and was surprised to find the redirects in wpcommon-php7.conf. Commented them out, but they really shouldn't be in here.
Can someone perhaps help me out with what I actually need to change to fix this in EE?
I've tried commenting out the block in /etc/nginx/common/wpcommon.conf but the 404 error remains even after flushing the permalinks and purging the cache.
@geckoseo you may be on PHP7 which means you'll have to remove them from wpcommon-php7.conf too... also: do not forget to restart/reload nginx for the new rules to kick in.
@RavanH thanks very much for the assistance. It was in the php7 file. What a crazy workaround, I really hope EE fixes this.
Yes, this is truly a crazy work around since it will disappear as soon as there's an EE update, which at their current rate of updates could be ooh, any decade now.
Closing this issue as it has been fixed in #949