[thelist] htaccess mod_rewrite help please!!!

David Kaufman david at gigawatt.com
Tue Oct 3 22:58:40 CDT 2006


Hi Stephen,

Stephen Rider <evolt_org at striderweb.com> wrote:
> I have Wordpress ... in one directory /blog/ and a symbolic link,
> /blog2/ (and /blog3/, /blog4/...) that points to the /blog/
> directory [as] detailed here:
> <http://www.mertner.com/allan/index.php?p=23>
>
> Everything working swimmingly so far.  Except...
> Wordpress uses a default mod_rewrite (in the /blog/.htaccess file)
> to customize the hierarchy of posts [...] Can anyone help me rework
> this?  I want to tell the rewrite block, essentially, "If the
> directory structure starts with /blog/, point to /blog/index.php.
> If it starts with /blog2/ point to /blog2/index.php

mod_rewrite rules (in an .htaccess file) cannot redirect requests 
(internally) up to a parent directory and back down to a *sibling* 
directory like that.  By the time the per-directory .htaccess files are 
parsed, it's too late for that.  You need to remove their rewrite rule 
in the /blog/ dir, modify it and place it in an .htaccess file one 
directory *up*, in this case, the document root of your site.

Try this, in /.htaccess

RewriteEngine On
RewriteCond %{REQUEST_URI}        ^/blog([0-9]*)/
RewriteCond %{REQUEST_FILENAME}   !-f
RewriteCond %{REQUEST_FILENAME}   !-d
RewriteRule .                     /%1/index.php [L]

hth,

-dave 




More information about the thelist mailing list