我有一个在 DigitalOcean 液滴上运行的多站点 WordPress 安装。我添加了 Apache 的mod_cache
模块来缓存我网站上的内容,但我遇到了一个非常奇怪的问题。在我设置缓存后的第一个页面加载时,网站加载正常。但是,在随后的页面加载中,我得到了目录索引而不是 index.php 被调用:
如果我清除缓存,下一页可以正常工作。似乎mod_cache
正在缓存目录索引 HTML 页面,而不是index.php
.
这是我的站点配置:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName jeremydormitzer.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/jeremydormitzer.com
ErrorLog /var/log/jeremydormitzer.com/error.log
CustomLog /var/log/jeremydormitzer.com/access.log combined
<Directory /var/www/html/jeremydormitzer.com/>
AllowOverride All
</Directory>
RewriteEngine on
LoadModule cache_module modules/mod_cache.so
<IfModule mod_cache.c>
LoadModule cache_disk_module modules/mod_cache_disk.so
<IfModule mod_cache_disk.c>
CacheEnable disk /
CacheDisable /wp-admin
</IfModule>
CacheLock on
CacheLockPath "/tmp/mod_cache-lock"
CacheLockMaxAge 5
CacheDisable "http://security.update.server/update-list/"
</IfModule>
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/qa.getpterotype.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/qa.getpterotype.com/privkey.pem
</VirtualHost>
</IfModule>
这是我的cache_disk.conf
:
<IfModule mod_cache_disk.c>
CacheRoot /var/cache/apache2/mod_cache_disk
CacheDirLevels 2
CacheDirLength 1
</IfModule>
这是我的apache2.conf
:
Mutex file:${APACHE_LOCK_DIR} default
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
HostnameLookups Off
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
Include ports.conf
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/html>
AllowOverride All
</Directory>
AccessFileName .htaccess
<FilesMatch "^\.ht">
Require all denied
</FilesMatch>
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*.conf
ServerName 104.236.87.208
UseCanonicalName On
有谁知道这是怎么回事?
更新
根据要求,这是我网站.htaccess
根路径下的内容:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>