首页 文章

WordPress在子目录的子目录中[关闭]

提问于
浏览
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');

主页加载正常,但任何内页页面错误"Not Found"错误: http://playstartshere.com/gallery/specs/ 产生 The requested URL /gallery/specs/ was not found on this server.

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

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

但这完全破坏了网站 .

EDIT: ANSWER

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>

希望能帮助别人 .

1 回答

  • 0

    /gallery/specs/ 与此规则匹配:

    RewriteRule ^index\.php$ - [L]
    

    阻止访问

    试试 /gallery/.htaccess

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

    如果没有 / prepending index.php,apache将在当前目录中搜索

    edit

    再次采用不同的方法:

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

    把一个.htaccess放在/ gallery / cms中

    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]
    

相关问题