You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by thomas Armstrong <ta...@gmail.com> on 2014/10/26 13:14:34 UTC

[users@httpd] htaccess in a directory under one with another htaccess

Hi.

On my Apache Server, I have this structure to host a website under '/' and
a WordPress blog under '/myblog' directory:
--- root_directory/.htaccess
--- root_directory/php_stuff
--- root_directory/myblog/.htaccess
--- root_directory/myblog/php_wp_stuff

Within 'root_directory/.htaccess' file I have several RewriteRules:
--------
RewriteRule ^item/([^/]+)/ /item.php?label1=$1 [L]
RewriteRule ^([^/]+)/([^/]+)/$ /category.php?label1=$1&label2=$2 [L]
-----------------------
which work with
http://www.example.com/item/book-10003/ and
http://www.example.com/science/maths/

However, if I try to access
http://www.example.com/myblog/ or
http://www.example.com/myblog/hello-world/

I got a 404 error. So I modififed the .htaccess:
------------------
RewriteRule ^myblog - [L,NC]
RewriteRule ^item/([^/]+)/ /item.php?label1=$1 [L]
RewriteCond %{REQUEST_URI} !^/myblog/
RewriteRule ^([^/]+)/([^/]+)/$ /category.php?label1=$1&label2=$2 [L]
-------------------
I tried to avoid 'myblog' directory to be ruled by the 'RewriteRules'.
However, it works with

http://www.example.com/myblog/
but not with http://www.example.com/myblog/hello-world/

What am I doing wrong? I also tried by adding these lines at the bottom of
.htaccess, but I does not work:
--------------
RewriteBase /myblog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /myblog/index.php [L]
--------------------
Any tip is welcome. Thank you very much.