views:

544

answers:

3

I'm having an issue with a rewrite.

I have a Wordpress install in my /blog directory, but I want the Wordpress Pages to appear outside of the blog directory.

So, in my root .htaccess I added a line: (The first three lines were already there for redirecting everything to "www"

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

RewriteRule ^(.*)$ "/blog/$1" [L]

I then changed the display URL within Wordpress to my root URL, and altered the permalink structure to prepend "/blog/" so it appeared my posts were still in the blog directory.

Everything works fine, but I can't get www.tooboss.com/blog to redirect to www.tooboss.com. Instead, it throws a 404.

Any ideas?

For reference, here's the blog directory's .htaccess file"

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>

# END WordPress

Am I missing something obvious? I feel like it's getting caught between the 2 htaccess files but I'm not sure what to do to fix it.

Thanks

+1  A: 

Wouldn't this rule:

RewriteRule ^(.*)$ "/blog/$1" [L]

cause www.tooboss.com/blog to get sent to www.tooboss.com/blog/blog?

I think you want:

RewriteCond %{REQUEST_FILENAME} !^/blog/$
RewriteRule ^(.*)$ "/blog/$1" [L]

I'm kind of new to .htaccess myself so I might be off base here.

seth
That code has the same issue.I need www.tooboss.com/* to get rewritten to www.tooboss.com/blog/* because that's the directory my blog resides in. In the case of www.tooboss.com/blog[/] though, I want a 301 to www.tooboss.comThanks
Colin
A: 

In response to your comment to seth's answer, try this:

RewriteRule ^/blog/?$ / [R=301,L]
RewriteRule ^(.*)$ /blog/$1 [L]
David Zaslavsky
This also has no effect.
Colin
A: 

I figured it out Very annoying issue. I was able to solve the issue without moving my blog to a different named directory, but it required altering the Wordpress PHP which I didn't want to do. If Wordpress was built to handle static links in the Permalink structure I wouldn't have needed to move the install

Colin