regex - 在单词后用 4 个数字替换 URL 模式

标签 regex apache .htaccess mod-rewrite url-rewriting

如何替换:

domain.com/e-books/1234-etc  

通过:

domain.com/artigos/1234-etc

我正在尝试:

RewriteRule ^e-books(\d{4}-.*)$ /artigos/(\d{4}-.*)$1 [R=301,L]

编辑:还有这个:

RewriteRule ^e-books(\d{4}-.*) /artigos/$1 [R=301,L]

最佳答案

RewriteRule ^e-books/(.+)$ /artigos/$1 [NC,R,L]

在测试之前清除浏览器的缓存。

关于regex - 在单词后用 4 个数字替换 URL 模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35197973/

相关文章:

Apache:在带有 AllowOverride None 的 conf 中包含 htaccess,性能更好?

ruby - 基于正则表达式生成随机字符串?

c# - 我无法弄清楚的正则表达式问题(负面回顾)

linux -/usr/bin/env 关于 shebang 行特性的问题

javascript - Steam 发布请求 - 无法加载资源 : the server responded with a status of 400 (Bad Request)

php - 如何将 URL 指向页面?

java - 将 String 替换为另一个直到行尾

regex - 开头和结尾空白的缩写

android - Apache HTTP 库在 API 27 中不起作用

apache - 从 rewriteRule 中绕过/排除一组特定的 URL