.htaccess 通过htaccess将旧URL重定向到新URL

.htaccess 通过htaccess将旧URL重定向到新URL,.htaccess,.htaccess,我现在有一堆URL要重定向到它们的新URL:我基本上必须从一开始就删除“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 这是

我现在有一堆URL要重定向到它们的新URL:我基本上必须从一开始就删除“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
编辑:


我想你在新的URL中缺少了“uri”。写下我想下次用“uri”替换“blog:)不,我不想替换任何内容。我需要在中间添加“URI”,然后删除“博客”,这是开始的。哦,对不起,我的坏,还没有滚动到代码的末尾。我已经编辑了我的答案。从[]中删除L,只需离开[R=301]
RewriteRule ^blog/(.*)$ http://domain.net/uri/$1 [R=301]
RewriteRule ^blog/posts/view/(.*)$ http://domain.net/posts/view/uri/$1 [R=301]