views:

3367

answers:

1

Hi,

I have the following problem. I have a website and a blog in a subdirectory. Both of them are php. I have a .htaccess file in the root folder and another one in the blog folder. I dont' think is relevant, but the blog script is wordpress.

I added a condition in the root .htaccess to skip the requests made for the blog,

rewriteCond %{REQUEST_URI} !^/blog.*

Here it is how it looks. I removed the rest of the file:

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

The problem I have is related to the blog requests. For example sometimes if I try to open an url it works fine, sometimes the home (root page not the blog) is opened. It seems very strange. I think it is related to the host. When the host is to busy the blog page I request is not found so the request is going to the root .htaccess.

I have 2 questions:

  • how to write a rule and where to place it to exclude all the requests for /blog to be rewritten by the root .htaccess? the blog requests might look like http: //test.com/blog, http: //test.com/blog/, http: //test.com/blog/title, http: //test.com/blog/title/, http: //test.com/blog/category/title
  • does anyone has any idea what happens? Why when I open a blog page it opens the home root page, and if I refresh the page it goes to the blog post page?
+1  A: 

Take a look into the mod_rewrite documentation, specifically the -d flag in RewriteCond.

It should be something like this:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule HERE
Alix Axel