0

这应该很简单 - 无法弄清楚我哪里出错了:

我们在以下位置安装了 WordPress:http ://example.com/gallery/cms ,我希望该网站在http://example.com/gallery上可见

我将 WordPress 地址设置为http://example.com/gallery/cms并将站点地址设置为http://example.com/gallery

我将 .htaccess 和 index.php 复制到 /gallery 文件夹。.htaccess 包含以下代码:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /gallery/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /gallery/index.php [L]
</IfModule>

index.php 包含以下代码:

define('WP_USE_THEMES', true);
require('./cms/wp-blog-header.php');

主页加载正常,但任何内部页面都会出现“未找到”错误:http://playstartshere.com/gallery/specs/yieldThe requested URL /gallery/specs/ was not found on this server.

我哪里错了?我尝试将 index.php 更改为:

define('WP_USE_THEMES', true);
require('./gallery/cms/wp-blog-header.php');

但这完全破坏了网站。

编辑:答案

Apache 确实配置不正确;未启用 RewriteEngine。但是,.htaccess 也是错误的。正确的 .htaccess 对于上面的配置是:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /gallery/cms/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /gallery/cms/index.php [L]
</IfModule>

希望对其他人有所帮助。

4

1 回答 1

0

/gallery/specs/符合此规则:

RewriteRule ^index\.php$ - [L]

哪个阻止访问

尝试/gallery/.htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]

没有/预先添加 index.php,apache 将在当前目录中搜索

编辑

再次采用不同的方法:

将所有 wordpress URL 设置为http://example.com/gallery 将所有 wordpress 文件放在 /gallery/cms

在 /gallery/cms 中放一个 .htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]

将第二个 .htaccess 放在 /gallery 中(没有 index.php)

RewriteEngine On
RewriteCond %{REQUEST_URI} !/gallery/cms
RewriteRule ^(.*)$ /gallery/cms/$1 [L]
于 2012-05-10T07:09:59.447 回答