wp-media / wp-rocket

Performance optimization plugin for WordPress
https://wp-rocket.me
GNU General Public License v2.0
699 stars 218 forks source link

Openlitespeed Server Downloads Pages as Files #2409

Open thekendog opened 4 years ago

thekendog commented 4 years ago

Describe the bug I'm using the plugin on an Openlitespeed server. When enabled, at random times when I go to a page as an anonymous user the browser downloads it as a file (called download). It is not consistent and I can't intentionally replicate it. When I see the issue and then deactivate the plugin I do not get this issue. This is not the first site, nor the first OLS server I've seen this behavior on.

To Reproduce Steps to reproduce the behavior:

  1. Install WP Rocket.
  2. Go to website in incognito.
  3. Pages randomly download as a file.

Expected behavior Page loads as normal

GeekPress commented 4 years ago

Hi @thekendog 🤚

We weren't able to reproduce the issue. May I kindly ask you a screencast (video) of the problem? Or if you still have the issue, could you please open a ticket support (https://wp-rocket.me/support/) and provide your WordPress and FTP access.

Thanks

thekendog commented 4 years ago

So I figured out the issue and it's some kind of error in my WP Rocket import file I believe. I have two sites both on OLS. One is working fine and the other isn't. Both are running 3.5.1. I looked in .htaccess. The one that wasn't working and was downloading had this in it.

` AddType text/html .html_gzip AddEncoding gzip .html_gzip

SetEnvIfNoCase Request_URI \.html_gzip$ no-gzip RewriteEngine On RewriteBase / RewriteCond %{HTTPS} on [OR] RewriteCond %{SERVER_PORT} ^443$ [OR] RewriteCond %{HTTP:X-Forwarded-Proto} https RewriteRule .* - [E=WPR_SSL:-https] RewriteCond %{HTTP:Accept-Encoding} gzip RewriteRule .* - [E=WPR_ENC:_gzip] RewriteCond %{REQUEST_METHOD} GET RewriteCond %{QUERY_STRING} ="" RewriteCond %{HTTP:Cookie} !(wordpress_logged_in_.+|wp-postpass_|wptouch_switch_toggle|comment_author_|comment_author_email_) [NC] RewriteCond %{REQUEST_URI} !^(/(.+/)?feed/?|/(?:.+/)?embed/|/(index\.php/)?wp\-json(/.*|$))$ [NC] RewriteCond %{HTTP_USER_AGENT} !^(facebookexternalhit).* [NC] RewriteCond "%{DOCUMENT_ROOT}/wp-content/cache/wp-rocket/%{HTTP_HOST}%{REQUEST_URI}/index%{ENV:WPR_SSL}%{ENV:WPR_WEBP}.html%{ENV:WPR_ENC}" -f RewriteRule .* "/wp-content/cache/wp-rocket/%{HTTP_HOST}%{REQUEST_URI}/index%{ENV:WPR_SSL}%{ENV:WPR_WEBP}.html%{ENV:WPR_ENC}" [L] ` I removed those lines. EDIT: No clue why those rewrites were being added. Removing them works though.
GeekPress commented 4 years ago

@thekendog Sorry for the delay.

These rewrite rules are added to speed up the process to deliver a caching page.

May I kindly ask you to open a ticket support? Then one of our support engineer will be able to investigate directly on your website the problem.

Thanks

webtrainingwheels commented 3 years ago

@GeekPress please can you re-open this - we continue to have tickets about it

DahmaniAdame commented 3 years ago

Related ticket - https://secure.helpscout.net/conversation/1386879528/228665/ OLS sending application/octet-stream header for HTML pages when WP Rocket is activated. The htaccess file wasn't corrupt after enabling WP Rocket.​ Disabling our htaccess rules didn't fix the issue. Updating from 3.8.0.1 to 3.8.2 fixed the issue. Issue still there.

webtrainingwheels commented 3 years ago

Related (note that it's been reported on both LiteSpeed and OpenLiteSpeed)

DahmaniAdame commented 3 years ago

Related ticket - https://secure.helpscout.net/conversation/1399061409/232220/

jorgemartine00 commented 3 years ago

Related ticket: https://secure.helpscout.net/conversation/1398448947/232009

webtrainingwheels commented 3 years ago

https://secure.helpscout.net/conversation/1419454274/237650?folderId=377611

girlie commented 3 years ago

https://secure.helpscout.net/conversation/1435126684/242051/

NataliaDrause commented 3 years ago

Related: https://secure.helpscout.net/conversation/1479323608/254827 Removing htaccess rules didn't help.

ajayalag1974 commented 3 years ago

Facing same problem, using OpenLiteSpeed on AAPanel with WP Rocket.

Removing below line added by WP Rocket in .htaccess fixed the problem but probably disabled serving gzip - RewriteRule .* - [E=WPR_ENC:_gzip]

Any fix for this ?

UPDATE FOUND SOLUTION: Seems to have found the issue & its solution (although don't know the logic but applied some common sense). Solution - In .htaccess file of your website in rules added by WP Rocket change "RewriteRule .* - [E=WPR_ENC:_gzip]" to "RewriteRule .* - [E=WPR_ENC:-gzip]" Solution was inspired by another similar line which was 2 lines before above line which was using "-" instead of "_" (line was "RewriteRule .* - [E=WPR_SSL:-https]") so tried it and it worked, cache & gzip both working now without DOWNLOAD problem.

Would like some comment/feedback from WP Rocket about this change/solution.

urekmazino2021 commented 3 years ago

I'm using cyberpanel with open LiteSpeed and i have Same problem removing thaccess rules didn't help

socialpreneur commented 3 years ago

I'm also having the same issue. Right after activating WP rocket 3.8.8 on OLS, index.php gets downloaded on every site visit. Purging cache doesn't seem to fix the issue. My OLS was installed by RunCloud.

szuperman commented 3 years ago

I have this issue too, OpenLiteSpeed 1.6.21 and WP Rocket 3.9.0.1....

CriandoSites commented 3 years ago

Facing same problem, using OpenLiteSpeed on AAPanel with WP Rocket.

Removing below line added by WP Rocket in .htaccess fixed the problem but probably disabled serving gzip - RewriteRule .* - [E=WPR_ENC:_gzip]

Any fix for this ?

UPDATE FOUND SOLUTION: Seems to have found the issue & its solution (although don't know the logic but applied some common sense). Solution - In .htaccess file of your website in rules added by WP Rocket change "RewriteRule .* - [E=WPR_ENC:_gzip]" to "RewriteRule .* - [E=WPR_ENC:-gzip]" Solution was inspired by another similar line which was 2 lines before above line which was using "-" instead of "_" (line was "RewriteRule .* - [E=WPR_SSL:-https]") so tried it and it worked, cache & gzip both working now without DOWNLOAD problem.

Would like some comment/feedback from WP Rocket about this change/solution.

OMG It worked dude! Im using OpenLiteSpeed on CyberPanel

NataliaDrause commented 3 years ago

Related: https://secure.helpscout.net/conversation/1549828164/273461?folderId=3864740 changing "_gzip" to "-gzip" in HTTACESS fixes the download file problem

NataliaDrause commented 3 years ago

Related: https://secure.helpscout.net/conversation/1577737400/281636/

webtrainingwheels commented 3 years ago

https://secure.helpscout.net/conversation/1604881751/288291?folderId=377611

webtrainingwheels commented 3 years ago

A note about this solution: https://github.com/wp-media/wp-rocket/issues/2409#issuecomment-831159749

It's not a complete solution - by changing "_gzip" to "-gzip" all it's doing is making our rewrite rule not match anymore. This change will be overwritten in the future, when the htaccess is updated again. The best way to achieve the same is to remove this block of rules using the helper plugin: https://github.com/wp-media/wp-rocket-helpers/raw/master/htaccess/wp-rocket-htaccess-remove-rewrites/wp-rocket-htaccess-remove-rewrites.zip

OR by removing these GZIP rules: https://github.com/wp-media/wp-rocket-helpers/tree/master/htaccess/wp-rocket-htaccess-no-gzip

viobru commented 3 years ago

Related: https://secure.helpscout.net/conversation/1671447847/303273

khaledmokhtar commented 3 years ago

100% fixed if you do like this OpenLiteSpeed image image image image

or make file .htaccess like this BEGIN WordPress

RewriteEngine On RewriteBase / RewriteRule ^index.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] END WordPress

NataliaDrause commented 2 years ago

Related: https://secure.helpscout.net/conversation/1723986647/313814?folderId=3864740

DahmaniAdame commented 2 years ago

Related - https://secure.helpscout.net/conversation/1734006529/315448/

alfonso100 commented 2 years ago

related - https://secure.helpscout.net/conversation/1752773544/318466?folderId=2683093

NataliaDrause commented 2 years ago

related: https://secure.helpscout.net/conversation/1780011401/324558/ Removing htaccess rules didn't help.

NataliaDrause commented 2 years ago

Related: https://secure.helpscout.net/conversation/1807673458/329968 https://secure.helpscout.net/conversation/1811383384/330655

NataliaDrause commented 2 years ago

Related: https://secure.helpscout.net/conversation/1817901061/332041/

alfonso100 commented 2 years ago

Related: https://secure.helpscout.net/conversation/1831666216/334578/

WordPresseur commented 2 years ago

Related: https://secure.helpscout.net/conversation/1843889589/336805/

Nader-abdi commented 2 years ago

I have this issue too, OpenLiteSpeed 1.7.16 and WP Rocket 3.9.13....

jorgefduran commented 2 years ago

Same issue here... any solution? I have tested the @khaledmokhtar solution but not work for my.

NataliaDrause commented 2 years ago

related: https://secure.helpscout.net/conversation/1993869120/365002?folderId=3864740

DahmaniAdame commented 2 years ago

Related - https://secure.helpscout.net/conversation/2006581536/367880?folderId=3864735

DahmaniAdame commented 2 years ago

Related - https://secure.helpscout.net/conversation/2009007775/368396/

webtrainingwheels commented 2 years ago

https://secure.helpscout.net/conversation/2007438544/368071?folderId=377611

webtrainingwheels commented 2 years ago

https://secure.helpscout.net/conversation/2031962950/373679?folderId=5321805

mviniciosbarreto commented 1 year ago

https://secure.helpscout.net/conversation/2377755215/446100?folderId=7546764

sergio-gn commented 1 year ago

Facing same problem, using OpenLiteSpeed on AAPanel with WP Rocket.

Removing below line added by WP Rocket in .htaccess fixed the problem but probably disabled serving gzip - RewriteRule .* - [E=WPR_ENC:_gzip]

Any fix for this ?

UPDATE FOUND SOLUTION: Seems to have found the issue & its solution (although don't know the logic but applied some common sense). Solution - In .htaccess file of your website in rules added by WP Rocket change "RewriteRule .* - [E=WPR_ENC:_gzip]" to "RewriteRule .* - [E=WPR_ENC:-gzip]" Solution was inspired by another similar line which was 2 lines before above line which was using "-" instead of "_" (line was "RewriteRule .* - [E=WPR_SSL:-https]") so tried it and it worked, cache & gzip both working now without DOWNLOAD problem.

Would like some comment/feedback from WP Rocket about this change/solution.

I removed the gzip line and the website is working again. Same environment as described before: LiteSpeed and CyperPanel. To prevent the htaccess from happening again I used the nogzip sent by @webtrainingwheels.

Just a suggestion for the developers here: If a lot of users keep having problems and need to rely on helpers written as plugins, why not implement a new tab on the wp-rocket plugin named 'Helpers' with checkboxes for each problem, for example:

This way, it would be easier for nontechnical users to troubleshoot the problems and fix the problems. image

Samsiani commented 10 months ago

"RewriteRule . - [E=WPR_ENC:_gzip]” to “RewriteRule . - [E=WPR_ENC:-gzip]" in my .htaccsess fixed this

BorisBelica commented 8 months ago

WP Rocket Version 3.15.9 on OpenLiteSpeed server. Same error - downloading site.

"RewriteRule . - [E=WPR_ENC:_gzip]” to “RewriteRule . - [E=WPR_ENC:-gzip]"

Do not fixed error.

tonnick commented 3 weeks ago

me neither, this does not work. I tried to disable cache module on litespeed but no luck. issue is coming back after a while