开发者

.htaccess rewrite for all but domain itself to a subdirectory

开发者 https://www.devze.com 2022-12-22 06:14 出处:网络
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]

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 开发者_如何学Goto 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.


RewriteRule /(\w+)/([^/]+)  /blog/$1/$2 [R=301,L]
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号