raymor
Forum Replies Created
-
I’m not convinced your analysis of /*$ is correct though. Doesn’t that match anything, whether it ends with a / or not? I’m thinking the rule is trying to say match anything that ends with a slash, OR match ^$ I have no idea what scenario the double-slash rule is trying to match.
I think you’re right, I applied the not operator (!) in the wrong order. It says “don’t match it if it ends with something other than a slash”, doesn’t it?
The old pattern was:
! ^.*[^/]$
^.* = Start with any characters, or none. That’s meaningless, so we’ll remove it and we have:
![^/]$
! means “don’t match”. [^] means “any character other than a slash”. $ means “at the end”. So we have:
Don't match any character other than a slash, at the end
Getting rid of the negative:
Match if it's a slash at the end, or nothing at all at the end.
So I now think the best we can do is to just get rid of the meaningless ^.* and use:
![^/]$
Does that sound right?
The difference in the speed of the .htaccess is huge* – somewhere between 10 and 100 times. That matters when it hits the cache, meaning it doesn’t run any PHP. On the other hand. when it doesn’t hit the cache and it runs thousands of lines of PHP, the rewrite isn’t significant compared to the PHP.
I haven’t benchmarked it, but knowing the C code that it runs, there’s a huge difference in how many lines of code are run, and how many times key lines are repeated.
I’ll be actually testing a new installation, with the skip rules, in the next 2-36 hours so I can confirm there are no typos. Shortly after posting above, I did realize I had one error. This:
!^.*[^/]$
Should become:
/*$
I was wrong when I said:
/$
The difference being the case where it’s empty, there’s no slash
or any other characters
. (Just mydomain.com)* The “huge” speed difference mostly matters only if you care about speed / load, of course. It’s not nearly the slowest thing in WordPress, by a long shot, but people use WP Supercache because speed / load matters to them. In an application like MS Word, other slowness would dwarf this difference.
I’ll try to remember to follow up after this new site is tested. I’ve worked on the WPSC .htaccess before, but didn’t save it.
The wrong thing got pasted. The complete set should be:
# BEGIN WPSuperCache <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / #If you serve pages from behind a proxy you may want to change 'RewriteCond %{HTTPS} on' to something more sensible AddDefaultCharset UTF-8 RewriteCond %{REQUEST_URI} /$ RewriteCond %{REQUEST_URI} !// RewriteCond %{REQUEST_METHOD} !POST RewriteCond %{QUERY_STRING} != RewriteCond %{HTTP:Cookie} !(comment_author_|wordpress_logged_in|wp-postpass_) RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\"]+ [NC] RewriteCond %{HTTP:Profile} !^[a-z0-9\"]+ [NC] RewriteCond %{HTTP_USER_AGENT} !(2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800) [NC] RewriteCond %{HTTP_user_agent} !^(w3c\ |w3c-|acs-|alav|alca|amoi|audi|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-|dang|doco|eric|hipt|htc_|inno|ipaq|ipod|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-|lg/u|maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|palm|pana|pant|phil|play|port|prox|qwap|sage|sams|sany|sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo|teli|tim-|tosh|tsm-|upg1|upsi|vk-v|voda|wap-|wapa|wapi|wapp|wapr|webc|winw|winw|xda\ |xda-) [NC] RewriteCond %{HTTP:Accept-Encoding} gzip RewriteCond %{HTTPS} on RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{SERVER_NAME}/$1/index-https.html.gz -f RewriteRule ^(.*) "/wp-content/cache/supercache/%{SERVER_NAME}/$1/index-https.html.gz" [L] RewriteCond %{REQUEST_URI} /$ RewriteCond %{REQUEST_URI} !// RewriteCond %{REQUEST_METHOD} !POST RewriteCond %{QUERY_STRING} != RewriteCond %{HTTP:Cookie} !(comment_author_|wordpress_logged_in|wp-postpass_) RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\"]+ [NC] RewriteCond %{HTTP:Profile} !^[a-z0-9\"]+ [NC] RewriteCond %{HTTP_USER_AGENT} !(2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800) [NC] RewriteCond %{HTTP_user_agent} !^(w3c\ |w3c-|acs-|alav|alca|amoi|audi|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-|dang|doco|eric|hipt|htc_|inno|ipaq|ipod|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-|lg/u|maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|palm|pana|pant|phil|play|port|prox|qwap|sage|sams|sany|sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo|teli|tim-|tosh|tsm-|upg1|upsi|vk-v|voda|wap-|wapa|wapi|wapp|wapr|webc|winw|winw|xda\ |xda-) [NC] RewriteCond %{HTTP:Accept-Encoding} gzip RewriteCond %{HTTPS} !on RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{SERVER_NAME}/$1/index.html.gz -f RewriteRule ^(.*) "/wp-content/cache/supercache/%{SERVER_NAME}/$1/index.html.gz" [L] RewriteCond %{REQUEST_URI} /$ RewriteCond %{REQUEST_URI} !// RewriteCond %{REQUEST_METHOD} !POST RewriteCond %{QUERY_STRING} != RewriteCond %{HTTP:Cookie} !(comment_author_|wordpress_logged_in|wp-postpass_) RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\"]+ [NC] RewriteCond %{HTTP:Profile} !^[a-z0-9\"]+ [NC] RewriteCond %{HTTP_USER_AGENT} !(2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800) [NC] RewriteCond %{HTTP_user_agent} !^(w3c\ |w3c-|acs-|alav|alca|amoi|audi|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-|dang|doco|eric|hipt|htc_|inno|ipaq|ipod|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-|lg/u|maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|palm|pana|pant|phil|play|port|prox|qwap|sage|sams|sany|sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo|teli|tim-|tosh|tsm-|upg1|upsi|vk-v|voda|wap-|wapa|wapi|wapp|wapr|webc|winw|winw|xda\ |xda-) [NC] RewriteCond %{HTTPS} on RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{SERVER_NAME}/$1/index-https.html -f RewriteRule ^(.*) "/wp-content/cache/supercache/%{SERVER_NAME}/$1/index-https.html" [L] RewriteCond %{REQUEST_URI} /$ RewriteCond %{REQUEST_URI} !// RewriteCond %{REQUEST_METHOD} !POST RewriteCond %{QUERY_STRING} != RewriteCond %{HTTP:Cookie} !(comment_author_|wordpress_logged_in|wp-postpass_) RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\"]+ [NC] RewriteCond %{HTTP:Profile} !^[a-z0-9\"]+ [NC] RewriteCond %{HTTP_USER_AGENT} !(2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800) [NC] RewriteCond %{HTTP_user_agent} !^(w3c\ |w3c-|acs-|alav|alca|amoi|audi|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-|dang|doco|eric|hipt|htc_|inno|ipaq|ipod|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-|lg/u|maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|palm|pana|pant|phil|play|port|prox|qwap|sage|sams|sany|sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo|teli|tim-|tosh|tsm-|upg1|upsi|vk-v|voda|wap-|wapa|wapi|wapp|wapr|webc|winw|winw|xda\ |xda-) [NC] RewriteCond %{HTTPS} !on RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{SERVER_NAME}/$1/index.html -f RewriteRule ^(.*) "/wp-content/cache/supercache/%{SERVER_NAME}/$1/index.html" [L] </IfModule> # END WPSuperCache
Forum: Fixing WordPress
In reply to: Too Many Redirects / Canonical Problem?1. We used to have the site at https://www.cgblog.org, but for efficiency I’ve opted to drop the www. on the new site, and have .htaccess configured to redirect accordingly:
…
Is this something I’m doing wrong with our site, or is this a problem with WP’s handling of canonical URLs?That’s one of about 25 different things that cause
“canonical redirects” to explode.Canonical redirects break a LOT of things even when using
mature desktop browsers, so I’m sure they cause even
more problems on mobile browsers, some of which are about
as developed as IE 2.0.Some of the bigger problems you see on all browsers
are:Breaks if your site is accessible via https as well as http.
Breaks anything that uses cookies and is accessible as
https://www.site.com and site.com.
Breaks PHP sessions in many cases.
Breaks load balancing such as www1.site.com
and www2.site.com
I could go on and on, requiring the use of fully qualified
URLs via the redirect or the new “validation” of the base URL
just really screws up a lot of things.On the other hand, it does help your Google rank, but only
in the land of fairy tales. In the real world, Google already
assumes that https://www.site.com and site.com are the normally the same.
So the actual benefit is .. nothing. Just a huge pain in the
rear, causing all sorts of incompatibilities, for no reason
at all.Forum: Requests and Feedback
In reply to: Don’t save fully qualified domains in the databaseYou have the same problem if your site is accessible via https,
or uses cookies and is accessible as https://www.site.com and site.com,
and with PHP sessions, and with load balancing such as www1.site.com
and www2.site.com, and a dozen other things.
Requiring the use of fully qualified URLs just really screws up
a lot of things.On the other hand, it does help your Google rank, but only
in the land of fairy tales. In the real world, Google already
assumes that https://www.site.com and site.com are the normally the same.
So the actual benefit is .. nothing. Just a huge pain in the
rear, causing all sorts of incompatibilies, for no reason at all.