Jump to content

ProcessWire, nginx and the new ProCache htaccess rules


Spiria
 Share

Recommended Posts

I am writing here instead of the ProCache forum because I have the impression that several nginx experts could solve this. In its new version, Procache proposes new .htaccess rules that are difficult to translate into nginx rules. We currently have a problem with the trailing slash of URLs which gives us a bad score in SEO analysis tools such as semrush.com. 

Indeed, a canonical URL is either without or with "/", but cannot be served by both options. Although ProcessWire without ProCache respects this rule, ProCache has no difficulty serving both, which is considered an SEO optimisation fault. I believe that ProCache version 2 solves this problem with these new rules, but I can't understand the following. Does anyone have any idea how to translate this into a nginx rule?

Attached also the whole proposed .htaccess for ProcessWire.

# PROCACHE v2/31885be14d6cfb4b2b0d3e533260bded --------------------------------------------------
  RewriteCond %{REQUEST_METHOD} !=POST
  RewriteCond %{QUERY_STRING} !.*=.*
  RewriteRule ^.*/$ - [E=pwpcstep:pour,E=pwpcname:index]
  RewriteCond %{ENV:pwpcstep} "=pour"
  RewriteCond %{HTTP_COOKIE} !^.*(wire_challenge|wires_challenge).*$
  RewriteRule ^.*/$ - [E=pwpcstep:stir,E=pwpcpath:%{DOCUMENT_ROOT}/site/assets/ProCache-00478359c5e65dbada1075bfbd4]
  RewriteCond %{ENV:pwpcstep} "=stir"
  RewriteCond %{ENV:pwpcpath}/$0/%{ENV:pwpcname}.html -f
  RewriteRule ^.*$ - [E=pwpcstep:drink,E=pwpcfile:$0/%{ENV:pwpcname}.html]
  RewriteCond %{ENV:pwpcstep} "=drink"
  RewriteRule ^(.*) %{ENV:pwpcpath}/%{ENV:pwpcfile} [L]
  <ifModule mod_headers.c>
  Header set X-PWPC "ProCache" env=pwpcstep
  Header set X-Powered-By "ProcessWire CMS, ProCache" env=pwpcstep
  </ifModule>
  RewriteCond %{REQUEST_URI} "^/~?[-_.a-zA-Z0-9/]*$"
  # /PROCACHE -------------------------------------------------------------------------------------

 

.htaccess-procache

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...