大网数据广告活动
网站运营与故障问答

.htaccess redirect strip old system content from end of URL

· 52CE 我爱测

Looking to redirect all URLs which look similar to this: https://www.example.com/discussion/topix/random-page-title.133760/posts/1255466/rate?rating=13&_Token=78139%2C1464617730%2Ca42dfb1db7e54b51db1879075650aaf4a3c3323a to https…

问题原文

原帖链接 · Randomer11 · CC BY-SA 3.0

Looking to redirect all URLs which look similar to this:

https://www.example.com/discussion/topix/random-page-title.133760/posts/1255466/rate?rating=13&_Token=78139%2C1464617730%2Ca42dfb1db7e54b51db1879075650aaf4a3c3323a

to

https://www.example.com/discussion/topix/random-page-title.133760/

Basically removing the following from the URL:

posts/1255466/rate?rating=13&_Token=78139%2C1464617730%2Ca42dfb1db7e54b51db1879075650aaf4a3c3323a

They are parts of an old system.

已采纳解答

原帖链接 · grg · CC BY-SA 4.0

RedirectMatch 301 ^/discussion/topix/(.*)/posts/.*$ /discussion/topix/$1/

(.*) is a capturing group which matches anything preceding ‘posts’.
$1 outputs the capturing group as the destination for the redirect.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2017-10-11)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。