通过htaccess将旧网址重定向到新网址

时间:2011-01-02 18:32:25

标签: .htaccess

我目前有一堆网址要重定向到他们的新网址:我基本上必须从头开始删除'blog'并在其中添加'uri':

redirect 301 /blog/posts/view/follow-twitter http://domain.net/posts/view/uri/follow-twitter

redirect 301 /blog/posts/view/around-the-corner http://domain.net/posts/view/uri/around-the-corner

这是我拥有的.htaccess的其余部分:

Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward it to index.php
RewriteRule . index.php

1 个答案:

答案 0 :(得分:3)

RewriteRule ^blog/(.*)$ http://domain.net/uri/$1 [R=301]

编辑:

RewriteRule ^blog/posts/view/(.*)$ http://domain.net/posts/view/uri/$1 [R=301]