【问题标题】:Two .htaccess Two Sites两个 .htaccess 两个站点
【发布时间】:2013-03-05 17:25:24
【问题描述】:

我有一个自定义电子商务网站,其中有一个 .htaccess 文件。我现在正在使用 Wordpress 为其创建一个博客,并将其安装在一个名为 blog 的子目录中。

一切都很好,直到我登录到 Wordpress 管理面板并将永久链接结构更改为 %postname%。更改后,登录页面和.htaccess 为空。

我需要别人的帮助来检查我的 .htacess 文件并进行更改以允许 Wordpress 永久链接结构并确保它不会与主站点冲突。如果我将 Wordpress .htaccess 代码添加到底部的根 .htaccess 中,则博客工作正常,但主站点出现 404 错误。

根 .htaccess:

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^Home index.php
RewriteRule ^CompanyProfile about.php
RewriteRule ^ContactUs contact.php
RewriteRule ^Shopping-Basket inq.php
RewriteRule ^My-Account myacc.php
RewriteRule ^SiteMap sitemap.php
RewriteRule ^Terms-Conditions terms.php
RewriteRule ^Privacy-Policy privacy.php
RewriteRule ^Delivery-Information delivery.php
RewriteRule ^Returns-Policy returns.php
RewriteRule ^Disclaimer disclaimer.php
RewriteRule ^Clients clients.php

RewriteRule ^Search-Results result.php
RewriteRule ^Do-Login dologin.php
RewriteRule ^Member-Login login.php
RewriteRule ^Logout logout.php
RewriteRule ^Delete/([a-zA-Z0-9_-]+)$ delp.php?id=$1
RewriteRule ^Shopping-Basket/([a-zA-Z0-9_-]+)$ inq.php?msg=$1
RewriteRule ^ForgetPassword/([a-zA-Z0-9_-]+)$ forget.php?msg=$1
RewriteRule ^ForgetPassword forget.php
RewriteRule ^Checkout checkout.php
RewriteRule ^OrderStatus status.php
RewriteRule ^ChangePassword changepassword.php
RewriteRule ^CreateAccount/([a-zA-Z0-9_-]+)$ create.php?msg=$1
RewriteRule ^CreateAccount create.php
RewriteRule ^ChangeAccount chgaccount.php
RewriteRule ^Shipping shipping.php
RewriteRule ^SaveLogin savelogin.php
RewriteRule ^SaveOrder saveorder.php

RewriteRule ^sections/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ cproducts.php?SID=$2&MID=$1
RewriteRule ^bproducts/([a-zA-Z0-9_-]+)$ products.php?MID=$1
RewriteRule ^productdetail/([a-zA-Z0-9_-]+)$ prod_detail.php?PID=$1
RewriteRule ^products/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ bproducts.php?SID=$2&MID=$1
RewriteRule ^Details/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ large.php?PID=$3&SID=$2&MID=$1

RewriteCond %{HTTP_HOST} !^www.mydomain.co.uk$ [NC]
RewriteRule ^(.*)$ http://www.mydomain.co.uk/$1 [L,R=301

子目录/blog.htaccess:

<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>

【问题讨论】:

  • 得到了解决方案.... ' RewriteBase /blog/ RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d 重写规则。 /blog/index.php [L] ' 将这些添加到根 .httaccess 中,一切正常......
  • 如果您找到了问题的答案,请写下答案并接受:) meta.stackexchange.com/a/2729
  • 我已经写在上面的回复里了。 :)
  • 您写的是评论,而不是答案。对于社区来说,这个问题仍然没有答案

标签: php wordpress .htaccess e-commerce


【解决方案1】:
<IfModule mod_rewrite.c> 
RewriteBase /blog/ 
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /blog/index.php [L] 
</IfModule>

【讨论】:

    猜你喜欢
    • 2011-06-03
    • 2017-02-06
    • 2013-09-11
    • 2015-06-04
    • 1970-01-01
    • 2018-02-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多