簡體   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