processwire / processwire-requests

ProcessWire feature requests.
39 stars 0 forks source link

htaccess improvement: redirect to www. and https in a single request #500

Open jjozsi opened 10 months ago

jjozsi commented 10 months ago

To improve the performance when both www. and https:// redirection required, I combine them in a single step as follows:

  # 13D. Redirect to https AND www. in a single request
  RewriteCond %{HTTPS} off [OR]  
  RewriteCond %{HTTP_HOST} !^www\.  
  RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$  
  RewriteRule .* https://www.%1%{REQUEST_URI} [L,NE,R=301]

Having two redirections wastes valuable server time for no reason, having this option in some form in the Processwire htaccess.txt template could prove helpful. This has been working well for me over the last couple of years but I have to add it in every time I upgrade the core and htaccess file.