Before getting into details this is my problem: my local copy of a live WordPress site is downloading .php files instead of parsing them to html templates in any browser.
I have installed a local copy of a live WordPress Site using WordPress's Duplicator plugin (followed this tutorial). I have set up a virtualhost to work on the mentioned local site.
After installing it, the site is performing as it should normally. After some time using it though, either WAMP or my local site randomly changes its configuration and prompts me to download a file whenever I try to click on one of the links inside the administrator page or if I try to access the local site through the navigation bar.
I have searched for a fix but failed to find an answer that explains accurately why this is happening (of course I have tried to replicate what the answers suggested and also failed in fixing the issue).
Would REALLY appreciate it if someone has an answer.
The following are contents of my httpd.conf
and .htaccess
files:
httpd.conf
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php
AddType application/x-httpd-php .php3
PS: I only placed the section above as I saw this was speculated to be the one causing the issue.
.htaccess
# This file was updated by Duplicator on 2018-06-14 19:17:00. See .htaccess.orig for the original .htaccess file.
# Please note that other plugins and resources write to this file. If the time-stamp above is different
# than the current time-stamp on the file system then another resource has updated this file.
# Duplicator only writes to this file once during the install process while running the installer.php file.
# BEGIN WordPress
AddHandler application/x-httpd-php70 .php
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 6 hours"
ExpiresByType image/jpeg "access plus 6 hours"
ExpiresByType image/gif "access plus 6 hours"
ExpiresByType image/png "access plus 6 hours"
ExpiresByType text/css "access plus 6 hours"
ExpiresByType application/pdf "access plus 1 week"
ExpiresByType text/javascript "access plus 6 hours"
ExpiresByType text/html "access plus 10 minutes"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 3 hours"
</IfModule>
Header set X-Endurance-Cache-Level "2"
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^/wp-content/endurance-page-cache/ - [L]
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{QUERY_STRING} !.*=.*
RewriteCond %{HTTP_COOKIE} !(wordpress_test_cookie|comment_author|wp\-postpass|wordpress_logged_in|wptouch_switch_toggle|wp_woocommerce_session_) [NC]
RewriteCond %{DOCUMENT_ROOT}/wp-content/endurance-page-cache/$1/_index.html -f
RewriteRule ^(.*)$ /wp-content/endurance-page-cache/$1/_index.html [L]
</IfModule>
<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
.htaccess.180614190810.orig
# BEGIN WordPress
AddHandler application/x-httpd-ea-php70 .php
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 6 hours"
ExpiresByType image/jpeg "access plus 6 hours"
ExpiresByType image/gif "access plus 6 hours"
ExpiresByType image/png "access plus 6 hours"
ExpiresByType text/css "access plus 6 hours"
ExpiresByType application/pdf "access plus 1 week"
ExpiresByType text/javascript "access plus 6 hours"
ExpiresByType text/html "access plus 10 minutes"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 3 hours"
</IfModule>
Header set X-Endurance-Cache-Level "2"
<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
Before getting into details this is my problem: my local copy of a live WordPress site is downloading .php files instead of parsing them to html templates in any browser.
I have installed a local copy of a live WordPress Site using WordPress's Duplicator plugin (followed this tutorial). I have set up a virtualhost to work on the mentioned local site.
After installing it, the site is performing as it should normally. After some time using it though, either WAMP or my local site randomly changes its configuration and prompts me to download a file whenever I try to click on one of the links inside the administrator page or if I try to access the local site through the navigation bar.
I have searched for a fix but failed to find an answer that explains accurately why this is happening (of course I have tried to replicate what the answers suggested and also failed in fixing the issue).
Would REALLY appreciate it if someone has an answer.
The following are contents of my httpd.conf
and .htaccess
files:
httpd.conf
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php
AddType application/x-httpd-php .php3
PS: I only placed the section above as I saw this was speculated to be the one causing the issue.
.htaccess
# This file was updated by Duplicator on 2018-06-14 19:17:00. See .htaccess.orig for the original .htaccess file.
# Please note that other plugins and resources write to this file. If the time-stamp above is different
# than the current time-stamp on the file system then another resource has updated this file.
# Duplicator only writes to this file once during the install process while running the installer.php file.
# BEGIN WordPress
AddHandler application/x-httpd-php70 .php
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 6 hours"
ExpiresByType image/jpeg "access plus 6 hours"
ExpiresByType image/gif "access plus 6 hours"
ExpiresByType image/png "access plus 6 hours"
ExpiresByType text/css "access plus 6 hours"
ExpiresByType application/pdf "access plus 1 week"
ExpiresByType text/javascript "access plus 6 hours"
ExpiresByType text/html "access plus 10 minutes"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 3 hours"
</IfModule>
Header set X-Endurance-Cache-Level "2"
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^/wp-content/endurance-page-cache/ - [L]
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{QUERY_STRING} !.*=.*
RewriteCond %{HTTP_COOKIE} !(wordpress_test_cookie|comment_author|wp\-postpass|wordpress_logged_in|wptouch_switch_toggle|wp_woocommerce_session_) [NC]
RewriteCond %{DOCUMENT_ROOT}/wp-content/endurance-page-cache/$1/_index.html -f
RewriteRule ^(.*)$ /wp-content/endurance-page-cache/$1/_index.html [L]
</IfModule>
<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
.htaccess.180614190810.orig
# BEGIN WordPress
AddHandler application/x-httpd-ea-php70 .php
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 6 hours"
ExpiresByType image/jpeg "access plus 6 hours"
ExpiresByType image/gif "access plus 6 hours"
ExpiresByType image/png "access plus 6 hours"
ExpiresByType text/css "access plus 6 hours"
ExpiresByType application/pdf "access plus 1 week"
ExpiresByType text/javascript "access plus 6 hours"
ExpiresByType text/html "access plus 10 minutes"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 3 hours"
</IfModule>
Header set X-Endurance-Cache-Level "2"
<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
Share
Improve this question
edited Jun 16, 2018 at 12:08
fuxia♦
107k38 gold badges255 silver badges459 bronze badges
asked Jun 16, 2018 at 1:34
maumau
315 bronze badges
1
- For anyone who faces this problem, I have been trying a bunch of things to find the source of the issue. Until now, I've reinstalled WAMP and created another copy of my live website. The problem appears to be the .htaccess file inside the website's directory, it seems to change configuration every time I visit the permalink settings page. Will be posting comments for updates on this issue – mau Commented Jun 19, 2018 at 17:00
1 Answer
Reset to default 2So I've come to a conclusion after doing a couple of tests in my local environment. It appears whenever I go (literally just click) to the page to edit permalinks in the admin area, the .htaccess
file changes it's contents. I couldn't figure out why exactly this happens because I couldn't invest a whole lot of time in this issue. I wanted to change the settings of the permalinks because my post images weren't being displayed on the website. Ultimately, just don't go to the edit permalinks page on your local env and save a copy of your .htaccess
file right after installation in case you run into this problem.
Edit
I found what the problem is finally. Whenever I go into the admin panel and change the settings or click on settings the .htaccess
file adds this line at the beginning of the file:
AddHandler application/x-httpd-php70 .php
I just deleted the line and everything works fine now. It seems like the directive(AddHandler) can be used to change the version of PHP the web server uses to compile your files. More on this here