将具有常规表达式的301重定向到具有相似编号的其他url [英] Redirect 301 with regular expresions to other url with similar numeration

查看:60
本文介绍了将具有常规表达式的301重定向到具有相似编号的其他url的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将文章迁移到网站上,并且CMS系统转换了网址.

I migrated my articles in website, and the CMS system transform de URLs.

我需要重定向类似于以下内容的网址:

I need to redirect URLs similar to:

案例1. URL末尾相同的文章名称和不同的编号:

Example, Case 1. Same article name and diferent number at the end of URL:

原始网址: https://www.website.com/文件夹/文章名称2087

源URL https://www.website.com/文件夹/名称为r929/

示例,第2种情况. URL末尾具有相同的文章名称和不同的编号,但带有其他子文件夹:

Example, Case 2. Same article name and diferent number at the end of URL, but with other subfolder:

原始网址: https://www.website.com/文件夹/文章名称2087

源URL https://www.website.com/folder0/folder/name-of-the-article-r929/

非常感谢并嫁给圣诞节.

Many Thanks and Marry Christmas.

推荐答案

能否请您按照显示的示例尝试进行以下操作,编写并进行测试.在测试URL之前,请确保清除浏览器缓存.如果要重定向(也可以在浏览器中更改URL),然后在两个规则中都添加带有 L 标志的 R = 301 .

Could you please try following, written and tested with shown samples. Please make sure you clear your browser cache before testing your URLs. In case you want to redirect(change URL in browser too) then add R=301 with L flag in both the rules.

RewriteEngine ON
RewriteRule ^folder/name-of-the-article-r929/?$ folder/2087-name-of-the-article [L]
RewriteRule ^folder0/folder/name-of-the-article-r929/?$ folder/2087-name-of-the-article [L]

这认为您要将 http://localhost:80/folder/name-of-the-article-r929/重写为 http://localhost:80/folder/2087文章名称

AND http://localhost:80/folder0/folder/name-of-the-article-r929/ TO http://localhost:80/folder/2087-name.

其中 localhost 可能是您的域名.

这篇关于将具有常规表达式的301重定向到具有相似编号的其他url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆