5

I have a very strange problem with WordPress. I transferred website from one domain to another with the use of Duplicator plugin.

Everything works just fine but when I change something in settings and save them and after that go to the website or individual pages, this page is downloaded to my computer.

For example if my website is example.com after I go to that page the file is downloaded to my computer with the name example.com (.com is extension of the file).

If I delete .htacces file I can access main page again but other permalinks do not work.

I tried changing .htacces with the default one given at Wordpress webpage and everything works well until I change something in settings and save it again.

I tried reinstalling Wordpress via wp-admin/update-core.php. Everything went well with re-installation but the problem is still here.

After I save the settings my htaccess remains the same except one line:

AddHandler application/x-httpd-php70 .php

which is added at the beginning:

# BEGIN WordPress
AddHandler application/x-httpd-php70 .php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

After I manually delete that line everything works well again until I save settings again. Just for information my current php version is 7.1. I tried changing it in cPanel to 7.0 but that also didn't help.

Anyone have idea what this could be and how to solve it?

  • 1
    edit your question to show what is in .htaccess when the site doesn't work. – mmm Nov 10 '17 at 23:41
  • Yes you are right, sorry forgot to do that. Now its there. Thanks! – eklisiarh Nov 11 '17 at 7:22
  • You can try AddHandler application/x-httpd-php71 .php as your host supporting it – Drupalizeme Nov 11 '17 at 7:41
  • I tried that and this doesn't help. Only removing that line completely fixes the download problem. Besides even if I manually change that line every time I save settings it is being overwritten by Wordpress. So I need to find out which part of Wordpress adds this line and why. – eklisiarh Nov 11 '17 at 7:45
  • @eklisiarh I don't think wordpress do this. Maybe this is an auto install from the PLESK/CPANEL installation and added by them. Another way it will be a plugin modifying the htaccess – Drupalizeme Nov 11 '17 at 8:03
6

Ok I figured this out and I am providing answer just for the case that someone else experiences this problem.

The problem was in the plugin that was used on the original automatic installation of the Wordpress done via Mojo Marketplace.

The name of the plugin was Endurance PHP Edge and it was not in the normal plugin folder so it could not been deactivated. This plugin is used in order to setup PhP version in the htaccess file after saving it. It looks like this:

    if ( ! defined( 'WPINC' ) ) { die; }

define( 'EPE_VERSION', 0.1 );

if ( ! class_exists( 'Endurance_PHP_Edge' ) ) {
    class Endurance_PHP_Edge {
        function __construct() {
            $this->hooks();
        }

        function hooks() {
            add_filter( 'mod_rewrite_rules', array( $this, 'htaccess_contents' ), 99 );
        }

        function htaccess_contents( $rules ) {
            if ( file_exists( '/opt/cpanel/ea-php70/root/usr/bin/php-cgi' ) ) {
                $default_handler = 'application/x-httpd-ea-php70';
            } else {
                $default_handler = 'application/x-httpd-php70';
            }

            $handler = get_option( 'epe_php_handler', $default_handler );
            $handler = 'AddHandler ' . $handler . ' .php' . "\n";
            return $handler . $rules;
        }
    }
    $ebc = new Endurance_PHP_Edge;
}

and this was adding that line in my .htaccess file.

Why this line is causing every page to download is beyond my comprehension.

The solution was simply to delete mu-plugins folder which can be found inside wp-content folder.

| improve this answer | |
  • "Why this line is causing every page to download" - If it's not breaking PHP entirely then it's probably resulting in the Content-Type HTTP response header to be set incorrectly. It should be text/html for a normal page request. But if the browser receives something it does not understand then you'll get the download prompt. – MrWhite Nov 15 '17 at 14:53

Not the answer you're looking for? Browse other questions tagged or ask your own question.