在详细介绍之前,这是我的问题:我的本地WordPress网站正在下载.php 而不是在任何浏览器中将其解析为html模板。
我已经使用WordPress的复制器插件安装了一个WordPress网站的本地副本(followed this tutorial). 我已经建立了一个virtualhost来处理提到的本地站点。
安装后,站点正常运行。但是,使用一段时间后,无论是WAMP还是我的本地站点,只要我尝试单击管理员页面中的一个链接,或者如果我尝试通过导航栏访问本地站点,都会随机更改其配置并提示我下载文件。
我已经搜索了一个修复程序,但没有找到一个准确解释为什么会发生这种情况的答案(当然,我尝试了复制答案所建议的内容,但也未能解决问题)。
如果有人能回答,我会非常感激的。
以下是我的httpd.conf
和.htaccess
文件:
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:我只是把这一部分放在上面,因为我看到这被推测是导致问题的原因。
.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