简体   繁体   English

.htaccess从子文件夹重定向到保留根的路径

[英].htaccess redirect from subfolder to root keeping paths

I'm migrating a site so I need to redirect all content from a www.oldurl.com/subfolder to the www.newurl.com and keep all the links, for example: 我正在迁移网站,因此需要将所有内容从www.oldurl.com/subfolder重定向到www.newurl.com并保留所有链接,例如:

www.oldurl.com/subfolder/subfolder2

needs to redirect to 需要重定向到

www.newurl.com/subfolder2

AND

www.oldurl.com/subfolder/subfolder3/link.html

needs to redirect to 需要重定向到

www.newurl.com/subfolder3/link.html

my .htacess looks like this: 我的.htacess看起来像这样:

RewriteEngine on
RewriteRule ^subfolder/(.*)$ /$1 [R=301,L]

It is redirecting all www.oldurl.com/subfolder to www.newurl.com/ but does not follow the old paths it just sends all request to home page 它会将所有www.oldurl.com/subfolder重定向到www.newurl.com/,但不遵循旧路径,它只是将所有请求发送到主页

For new conditions new .htaccess 对于新条件,新的.htaccess

RewriteEngine on
RewriteRule ^subfolder/(.*)$ http://www.newurl.com/$1 [R=301,L] 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM