Php 如何在.htaccess中写入重写条件以排除子目录及其子目录

Php 如何在.htaccess中写入重写条件以排除子目录及其子目录,php,.htaccess,redirect,mod-rewrite,Php,.htaccess,Redirect,Mod Rewrite,我有以下问题。我在一个子目录中有一个网站和一个博客。它们都是php。我在根文件夹中有一个.htaccess文件,在博客文件夹中有另一个。我认为这不相关,但博客脚本是wordpress 我在root.htaccess中添加了一个条件来跳过对博客的请求 rewriteCond %{REQUEST_URI} !^/blog.* 这就是它的样子。我删除了文件的其余部分: Options +FollowSymlinks -MultiViews RewriteEngine on RewriteBase

我有以下问题。我在一个子目录中有一个网站和一个博客。它们都是php。我在根文件夹中有一个.htaccess文件,在博客文件夹中有另一个。我认为这不相关,但博客脚本是wordpress

我在root.htaccess中添加了一个条件来跳过对博客的请求

rewriteCond %{REQUEST_URI} !^/blog.*
这就是它的样子。我删除了文件的其余部分:

Options +FollowSymlinks -MultiViews RewriteEngine on

RewriteBase / RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.php\ HTTP/

// my added line RewriteCond %{REQUEST_URI} !^/blog.*


RewriteCond %{HTTP_HOST} !^www\. RewriteRule .* http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

RewriteRule ^(all)/([^/]+)/?$ story.php?title=$2 [L] RewriteRule ^(all)/?$ ?category=$1 [L]

RewriteRule ^/?$ index.php [L] RewriteRule ^advanced-search/?$ advancedsearch.php [L] ...
我遇到的问题与博客请求有关。例如,有时如果我尝试打开一个url,它会正常工作,有时会打开主页(根页面而不是博客)。这似乎很奇怪。我认为这与主持人有关。当主机忙时,找不到blog页面I请求,因此请求将转到root.htaccess

我有两个问题:

  • 如何编写规则以及在何处编写规则 放置它以排除所有请求 for/blog将由root用户重写 .htaccess?博客请求可能会被删除 看起来像http://test.com/blog, http://test.com/blog/, http://test.com/blog/title, http://test.com/blog/title/, http://test.com/blog/category/title
  • 有人知道会发生什么吗?为什么当我打开一个博客页面时,它会打开主页根页面,如果我刷新页面,它会转到博客帖子页面
查看,特别是RewriteCond中的-d标志

应该是这样的:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule HERE

你能不能把代码格式化,使它更“可读”(=换行符在正确的位置)?非常感谢。