开发者

Help in configuring .htaccess to exclude a path from rewriting

开发者 https://www.devze.com 2023-03-23 07:46 出处:网络
I have a root folder with the following .htaccess configuration RewriteEngine On RewriteCond %{HTTP_HOST} !^www\\.

I have a root folder with the following .htaccess configuration

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

What I need is, I have installed a wordpress site in a sub directory 'blog/'. Now I am able to access the home page of the blog since I have givien RewriteCond %{REQUEST_FILENAME} !-d. But clicking on a post will redirect me to the index file in root folder. How can I solve this. Please help. Thanks in advance.


Add a RewriteCond to exclude paths which begin with "blog/" Something like (added some existant rule for context)

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

Not tested, but you get the idea

0

精彩评论

暂无评论...
验证码 换一张
取 消