htacess-将文件夹重定向到新页面

时间:2018-09-27 09:56:51

标签: .htaccess redirect

我想将旧页面的一部分重定向到新页面。

我在域olddomain.com中有文件夹:olddomain.com/folder1和olddomain.com/folder2

在此文件夹中有例如页面

  • olddomain.com/folder1/page1
  • olddomain.com/folder1/page2
  • olddomain.com/folder1/page3
  • olddomain.com/folder1/page4
  • ....
  • olddomain.com/folder2/page1
  • olddomain.com/folder2/page2
  • olddomain.com/folder2/page3
  • olddomain.com/folder2/page4
  • olddomain.com/folder2/page5

例如,我想将一些旧的URL重定向到新域中的URL

  • olddomain.com/folder1/page1到newdomain.com/newpage
  • olddomain.com/folder1/page2到newdomain.com/newpage2
  • olddomain.com/folder2/page1到newdomain.com/newpage

我要重定向的其余URL都位于folder1和folder2中,请执行newdomain.com

可以吗?

RewriteEngine On
RewriteRule ^/folder1/(.*)$ http://newdomain.com/ [R=301,L]
RewriteRule ^/folder2/(.*)$ http://newdomain.com/ [R=301,L]
Redirect 301 /folder1/page1 newdomain.com/newpage
Redirect 301 /folder1/page2 newdomain.com/newpage2
Redirect 301 /folder2/page1 newdomain.com/newpage

0 个答案:

没有答案