我在public_html子目录中安装了Wordpress,假设/wordpress/
。 在根目录/public_html中没有索引文件。 在wordpress管理页面中,我设置了以下内容:
WordPress Address (URL): https://example.org/wordpress/
Site Address (URL): https://example.org/
这会在public_html根目录中生成.htaccess
(不在子目录/wordpress/
中(:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
这是不正确的:它不会重定向到正确的子目录,所以我将其修改为:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
现在它似乎有效:当我去https://example.org
时,我看到 wordpress 网站,链接中没有/wordpress/
。
人类有一个看不见的问题:如果我检查https标头响应,我会收到一个403 Forbidden
错误,可能与根目录中缺少索引文件有关。
这阻止了搜索引擎蜘蛛。
任何想法将不胜感激, 提前谢谢你, 吉尔
我认为你的情况与这个问题相同
你可以从wordpress中遵循这种方法。
已解决
按照@Nugie建议,解决方案是:
- 将
index.php
从/wordpress/
复制到public_html根
目录 - 在根目录中修改索引.php如下所示:
从:
require __DIR__ . '/wp-blog-header.php';
自:
require __DIR__ . '/wordpress/wp-blog-header.php';
现在到 403 禁止错误消失了。
谢谢@Nugie