htaccess的正则表达式重定向

编程入门 行业动态 更新时间:2024-10-13 10:26:28
本文介绍了htaccess的正则表达式重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有超过700的所有使用规则集重定向在htaccess文件。我无法搞清楚如何重定向多个页面的URL数字2-20。这里是我的非工作重定向:

I have over 700 redirects in a htaccess file all using RewriteRules. I'm having trouble figuring out how to redirect multiple pages with numbers 2-20 in the URL. Here are my non-working redirects:

RewriteRule ^orlando-airport/americas-best-cocoa-beach/1-person-fly-snooze-cruise-hotel-package.html$ /fly-snooze-cruise/orlando-airport/americas-best-cocoa/1-person [R=301,L] RewriteRule ^orlando-airport/americas-best-cocoa-beach/[0-9]-people-fly-snooze-cruise-hotel-package.html$ /fly-snooze-cruise/orlando-airport/americas-best-cocoa/$1-people [R=301,L] RewriteRule ^orlando-airport/double-tree-cocoa-beach/1-person-fly-snooze-cruise-hotel-package.html$ /fly-snooze-cruise/orlando-airport/doubletree-cocoa-beach/1-person [R=301,L] RewriteRule ^orlando-airport/double-tree-cocoa-beach/[0-9]-people-fly-snooze-cruise-hotel-package.html$ /fly-snooze-cruise/orlando-airport/doubletree-cocoa-beach/$1-people [R=301,L]

线1和3的工作,但2和4没有。人在网址的数量应为1人,然后2-20人。任何帮助将是AP preciated

Lines 1 and 3 work but 2 and 4 don't. The number of people in the URLs should be 1 person and then 2-20 people. Any help would be appreciated

推荐答案

你没有捕捉前pression,而你只允许一个数字。

You're not capturing the expression, and you're only allowing one digit.

使用([0-9] +)而不是 [0-9] :

RewriteRule ^orlando-airport/americas-best-cocoa-beach/1-person-fly-snooze-cruise-hotel-package.html$ /fly-snooze-cruise/orlando-airport/americas-best-cocoa/1-person [R=301,L] RewriteRule ^orlando-airport/americas-best-cocoa-beach/([0-9]+)-people-fly-snooze-cruise-hotel-package.html$ /fly-snooze-cruise/orlando-airport/americas-best-cocoa/$1-people [R=301,L] RewriteRule ^orlando-airport/double-tree-cocoa-beach/1-person-fly-snooze-cruise-hotel-package.html$ /fly-snooze-cruise/orlando-airport/doubletree-cocoa-beach/1-person [R=301,L] RewriteRule ^orlando-airport/double-tree-cocoa-beach/([0-9]+)-people-fly-snooze-cruise-hotel-package.html$ /fly-snooze-cruise/orlando-airport/doubletree-cocoa-beach/$1-people [R=301,L]

更多推荐

htaccess的正则表达式重定向

本文发布于:2023-10-31 13:40:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1546250.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重定向   正则表达式   htaccess

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!