Wednesday, December 31, 2014

.htaccess - Advanced Redirect 301 htaccess



I need through redirect 301 htaccess this:



Of these:



https://ejemplo.com/post-noticia/octubre-2019/122-nombre-de-mi-noticia



To this:



https://ejemplo.com/noticia/nombre-de-mi-noticia


I have tried this:



Redirect 301 /post-noticia/octubre-2019/ https://ejemplo.com/noticia/



But the result is:



https://ejemplo.com/noticia/122-nombre-de-mi-noticia


I need the result to be:



https://ejemplo.com/noticia/nombre-de-mi-noticia



That is, omit: 122-



Thank you


Answer



Have you tried Redirect 301 /post-noticia/octubre-2019/122- https://ejemplo.com/noticia/?



If 122- is a variable (you haven't gave a clue), you have to use either RedirectMatch which accepts regexps:



RedirectMatch 301 "/post-noticia/octubre-2019/\d+-(.+)$" "https://ejemplo.com/noticia/$1"



or fiddle with mod_rewrite.


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...