簡體   English   中英

.htaccess重定向忽略了URL的多個部分

[英].htaccess Redirect is ignoring several parts of the URL

我正在嘗試重定向

http://www.example.com/shop/childrens-shinnerz-by-size/extra-small

http://www.example.com/sports-goods/childrens-shinnerz/all-extra-small-5-7-yrs

用這種方式

Redirect 301 /shop/childrens-shinnerz-by-size/extra-small /sports-goods/childrens-shinnerz/all-extra-small-5-7-yrs

但是它重定向到錯誤的URL

http://www.example.com/sports-goods/childrens-shinnerz/extra-small

因此,部分all--5-7-yrs被忽略。

如何重定向到正確的URL?

使用this,它應該可以工作:

     RedirectMatch 301 http://www.example.com/shop/childrens-shinnerz-by-size/extra-small(.*) http://www.example.com/sports-goods/childrens-shinnerz/all-extra-small-5-7-yrs/$1

資料來源: http : //www.htaccessredirect.net/

如果您在網站的根目錄中使用.htaccess文件,

  RewriteRule ^shop/childrens-shinnerz-by-size/extra-small(.*)$ http://www.example.com/sports-goods/childrens-shinnerz/all-extra-small-5-7-yrs/$1 [R=301,NC,L]

我找到辦法

RedirectMatch 301 ^/shop/childrens-shinnerz-by-size/extra-small$ /sports-goods/childrens-shinnerz/all-extra-small-5-7-yrs

這是我想要的

我已經在服務器上對其進行了測試,並且工作正常
http://www.familybmi.com/shop/childrens-shinnerz-by-size/extra-small
也許您的Apache出了點問題,嘗試測試其他類似的東西

Redirect 301 /retiredpage.html http://www.example.com/newpage.html

並嘗試一下,如果沒有得到理想的結果,則意味着您可能需要更新您的apache

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM