繁体   English   中英

使用.htaccess将类别及其所有发布重定向到新的URL

[英]Redirect a category and all it's post to a new URL with .htaccess

我想将一个类别的所有URL重定向到新域。

例如,test.saptraininghub.com / sap-basis-training-tutorials / how-to-lockunlock-a-user-2到joomla5.guru99.com/how-to-lockunlock-a-user-2.html。 我想对所有此类网址执行此操作

和,

想要将test.saptraininghub.com/sap-basis-training-tutorials重定向到joomla5.guru99.com/sap-basis-training-tutorials.html。

我在.htaccess中写了以下指令

Redirect 301 /sap-basis-training-tutorials/ http://joomla5.guru99.com/sap-basis-training-tutorials.html
Redirect 301 /sap-basis-training-tutorials/how-to-lockunlock-a-user-2 http://joomla5.guru99.com/how-to-lockunlock-a-user-2.html

第一个重定向很好,但是在后一个中,显示页面未找到错误。 它实际上是重定向的,但不是正确的URL,而是在浏览器的地址栏中找到以下URL。

' http://joomla5.guru99.com/sap-basis-training-tutorials.htmlhow-to-lockunlock-a-user-2 '

我该如何解决此问题,请向正确的方向提供帮助并帮助我解决此问题。

问候。

对正则表达式功能使用RedirectMatch而不是Redirect

RedirectMatch 301 ^/sap-basis-training-tutorials/(.+?)/?$ http://joomla5.guru99.com/$1.html

RedirectMatch 301 ^/(sap-basis-training-tutorials)/?$ http://joomla5.guru99.com/$1.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM