Reputation: 2824
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
Upvotes: 0
Views: 1153
Reputation: 2824
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
Upvotes: 0
Reputation: 131690
In response to your comment to seth's answer, try this:
RewriteRule ^/blog/?$ / [R=301,L]
RewriteRule ^(.*)$ /blog/$1 [L]
Upvotes: 0
Reputation: 37287
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.
Upvotes: 1