想在子目录中运行wordpress并将我的主站点保持在根目录中

时间:2013-06-21 18:58:28

标签: wordpress

我在根目录中有一个电子商务网站,并希望将我的博客移动到子目录。我成功地从另一个域转移到了这个域,但是当我尝试访问博客主页时,它会重新定向到我的电子商务网站的主页。

电子商务网站 - http://www.heavytshirt.com 博客位置 - http://www.heavytshirt.com/blog

博客目录中的.htaccess文件如下所示:

    RewriteEngine on
    RewriteBase /

    # 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

并且根目录中的.htaccess文件如下所示:

    DirectoryIndex /mm5/merchant.mvc?Screen=SFNT

    RewriteEngine On

    RewriteRule ^mm5/admin.mvc? - [L]

    RewriteCond %{REQUEST_FILENAME} !-s
    RewriteRule ^product/([^/.]+).html$ /mm5/merchant.mvc?Screen=PROD&Product_code=$1 [L]

    RewriteCond %{REQUEST_FILENAME} !-s
    RewriteRule ^category/([^/.]+).html$ /mm5/merchant.mvc?Screen=CTGY&Category_code=$1 [L]

    RewriteCond %{REQUEST_FILENAME} !-s
    RewriteRule ^product/([^/]+)/([^/.]+).html$ /mm5/merchant.mvc?Screen=PROD&Category_code=$1&Product_code=$2 [L]

    RewriteCond %{REQUEST_FILENAME} !-s
    RewriteRule ^([^/.]+).html$ /mm5/merchant.mvc?Screen=$1 [L]

    ### End - Inserted by Miva Merchant

    Options +FollowSymlinks
    RewriteEngine On
    RewriteCond %{http_host} ^heavytshirt.com [nc]
    RewriteRule ^(.*)$ http://www.heavytshirt.com/$1 [r=301,nc]


    # 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

目前我可以输入后续子目录并进入帖子 - 喜欢: http://www.heavytshirt.com/blog/category/summershirts/

当有人在http://www.heavytshirt.com/blog输入内容时,我该怎么做才能让博客主页出现 并且不会影响www.heavytshirt.com

的主网站

2 个答案:

答案 0 :(得分:0)

我没有考虑你的apache配置,因为我相信它可以在WordPress中轻松配置。

进入WordPress管理面板,然后转到Settings / General Settings

现在相应地更改WordPress Address (URL)Site Address (URL)的值。请阅读this WordPress Codex article了解详情。

答案 1 :(得分:0)

您的问题是因为您已设置

DirectoryIndex /mm5/merchant.mvc?Screen=SFNT

因为/ blog /是一个目录,你设置的规则与/ blog /的目录索引匹配(因为目录实际存在)。

您必须将两个重写指令结合起来才能获得所需的结果(在那里不需要RewriteEngine On两次)。

从头开始逐行测试以确保获得所需的结果可能更好。

我无法测试这个,但你明白了:

Options +FollowSymlinks

RewriteEngine On

RewriteBase /
RewriteRule ^mm5/admin.mvc? - [L]
RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule ^product/([^/.]+).html$ /mm5/merchant.mvc?Screen=PROD&Product_code=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule ^category/([^/.]+).html$ /mm5/merchant.mvc?Screen=CTGY&Category_code=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule ^product/([^/]+)/([^/.]+).html$ /mm5/merchant.mvc?Screen=PROD&Category_code=$1&Product_code=$2 [L]
RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule ^([^/.]+).html$ /mm5/merchant.mvc?Screen=$1 [L]
RewriteCond %{http_host} ^heavytshirt.com [nc]
RewriteRule ^(.*)$ http://www.heavytshirt.com/$1 [r=301,nc]

RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]