.htaccess rewrite for all but domain itself to a subdirectory

Posted by romant on Stack Overflow See other posts from Stack Overflow or by romant
Published on 2010-03-10T08:18:51Z Indexed on 2010/05/14 10:04 UTC
Read the original article Hit count: 286

Filed under:

Hi,

There exists a blog at domain.com

I wish to do a 301 redirect on anything that is after domain.com/[category/[post-name] to domain.com/blog/[category]/[post-name]

The key here is when someone hits domain.com they just stay there. Only if there's any reference to posts within domain.com that I wish for the redirect to work.

Will hold this for at most 6 months, until SEO settles, and then remove the redirect.

What is the best way of achieving this with .htaccess ?

The current one is as follows:

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

Any help is appreciated.

Thank you.

© Stack Overflow or respective owner

Related posts about .htaccess