tl; dr
-
mod_rewrite
已加载 -
.htaccess
是可写的 -
AllowOverride ALL
是设置 -
LogLevel debug
已设置 - 日志显示一个重定向循环(请参见下文(
详细信息
WordPress博客位于文件系统位置/var/www/html/
(即index.php
都在其中,所有wp-*.php
文件(例如wp-settings.php
(也是如此(。
WordPress博客的常规设置 for WordPress地址(url( and site> site> site Address(url(都设置为 https://example.com/blog
。
当我将永久链接设置设置为为一个月和名称(或其他任何内容 plain (以外,.htaccess
文件被自动修改以包含以包含以下mod_rewrite
块,URL路径相应调整,例如/blog/2019/03/hello-world/
,但是访问URL会导致内部服务器错误。
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
# END WordPress
日志显示以下内容:
Request exceeded the limit of 10 internal redirects due to probable configuration error.
AH00121: r->uri = /blog/index.php, referer: https://staging.example.com/blog/
AH00122: redirected from r->uri = /blog/index.php, referer: https://staging.example.com/blog/
... the above line repeated ...
AH00122: redirected from r->uri = /2019/03/10/hello-world/, referer: https://staging.example.com/blog/
成功的提示...
使用永久链接设置设置为 plain ,.htaccess
文件本质上是空的,链接可以正常工作,尽管它们具有不可避免的表格/?p=123
:
# BEGIN WordPress
# END WordPress
当我设置自定义结构,到/index.php/%year%/%monthnum%/%postname%/
时,博客链接已更新为格式 /blog/index.php/2019/03/hello-world/
,它们可以工作,但是现在URL丑陋(/index.php/
(。
那么,为什么它不适用于/%year%/%monthnum%/%postname%/
,并且自动设置.htaccess
指令?
血腥详细信息
这无关紧要,但是对于记录:此 WordPress Blog 托管在 Virtual Machine实例( VM实例(中计算引擎 Google Cloud Platform 。
从最后一个规则中删除 /blog
(RewriteBase
如前所述(。
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress