Regex 将URL模式替换为单词后的4个数字
如何替换:Regex 将URL模式替换为单词后的4个数字,regex,apache,.htaccess,mod-rewrite,url-rewriting,Regex,Apache,.htaccess,Mod Rewrite,Url Rewriting,如何替换: domain.com/e-books/1234-etc 作者: 我正在努力: RewriteRule ^e-books(\d{4}-.*)$ /artigos/(\d{4}-.*)$1 [R=301,L] 编辑:这个: RewriteRule ^e-books(\d{4}-.*) /artigos/$1 [R=301,L] 测试之前请清除浏览器的缓存。在替换中,您只能使用$1反向引用左侧模式中的捕获组值。您不能在替换中使用(\d{4}-.*)。尝试一下e-books/(\d
domain.com/e-books/1234-etc
作者:
我正在努力:
RewriteRule ^e-books(\d{4}-.*)$ /artigos/(\d{4}-.*)$1 [R=301,L]
编辑:这个:
RewriteRule ^e-books(\d{4}-.*) /artigos/$1 [R=301,L]
测试之前请清除浏览器的缓存。在替换中,您只能使用
$1
反向引用左侧模式中的捕获组值。您不能在替换中使用(\d{4}-.*)
。尝试一下e-books/(\d{4}-.*)
模式和/artigos/$1
这样的替换?重写规则^e-books(\d{4}-.*)$/artigos/$1[R=301,L]您编辑的规则应该很有用,它对您很有用。
RewriteRule ^e-books(\d{4}-.*) /artigos/$1 [R=301,L]
RewriteRule ^e-books/(.+)$ /artigos/$1 [NC,R,L]