帮助配置.htaccess以从重写中排除路径

帮助配置.htaccess以从重写中排除路径,.htaccess,mod-rewrite,url-rewriting,.htaccess,Mod Rewrite,Url Rewriting,我有一个根文件夹,配置如下.htaccess RewriteEngine On RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] # if a directory or a file exists, use it directly RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !

我有一个根文件夹,配置如下.htaccess

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward it to index.php
RewriteRule . index.php

我需要的是,我已经在一个子目录
'blog/'
中安装了一个wordpress站点。现在我可以访问博客的主页了,因为我有了givien
RewriteCond%{REQUEST_FILENAME}-d
。但是点击一篇文章会将我重定向到根文件夹中的索引文件。我怎样才能解决这个问题。请帮忙。提前感谢。

添加重写条件以排除以“blog/”开头的路径 类似(为上下文添加了一些现有规则)

没有经过测试,但你明白了

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/?blog/