我不确定如何在.htaccess中正确编写指令以获取这样的URL:
www.domain.com/photo/weather/p1741-high-stress.html
www.domain.com/photo/cultural-practices/p1752-thermal-convection.html
www.domain.com/photo/turf-diseases/p1748-algae-and-viruses.html
为:
www.domain.com/gallery/detail/high-stress
www.domain.com/gallery/detail/thermal-convection
www.domain.com/gallery/detail/algae-and-viruses
基本上是这样的:
photo
更改为gallery
detail
p#####-
).html
答案 0 :(得分:1)
您可以使用:
RewriteEngine on
RewriteRule ^photo/[^/]+/p\d+-(.+)\.html$ gallery/detail/$1 [NC,R=301,L]
答案 1 :(得分:0)
正则表达式匹配原始网址:
www\.domain\.com/photo/[^/]+/p\d+-(.+?)\.html
将其替换为:
www.domain.com/gallery/detail/$1