【问题标题】:Want to run wordpress in a subdirectory and keep my main site separate in the root想要在子目录中运行 wordpress 并将我的主站点与根目录分开
【发布时间】:2013-06-21 18:58:28
【问题描述】:

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

电子商务网站 - 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的主站

【问题讨论】:

    标签: wordpress


    【解决方案1】:

    我没有调查您的 apache 配置,因为我相信它可以在 WordPress 中轻松配置。

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

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

    【讨论】:

    • 问题是,我不想编辑我的主要 .htaccess,因为它控制着我的电子商务网站的工作方式,我不需要它被打断。我继续尝试了其他一些事情,例如将 index.php 的副本移动到根目录并按照说明进行编辑,现在我无法访问我博客的任何页面,即使我输入url 一直进去。我把所有东西都改回了以前的样子,现在什么都没有了。现在我有麻烦了。
    【解决方案2】:

    你的问题是因为你设置了

    DirectoryIndex /mm5/merchant.mvc?Screen=SFNT
    

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

    您必须将两个 Rewrite 指令结合起来才能获得所需的结果(您不需要 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]
    

    【讨论】:

      猜你喜欢
      • 2012-02-03
      • 1970-01-01
      • 2016-06-18
      • 2021-02-10
      • 2011-02-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多