我試圖對待一個URL與htaccess和%{REQUEST_URI}參數。我研究了很多,使用htaccess.madewithlove.be和虛擬機來構建規則並測試沒有成功。很難改變和分開REQUEST_URI與htaccess
請求的URL是:
1)www.example.com.br/category/product/Beer?id=16
請求的URL,以更好地理解Anothe例如:
2)www.example.com.br/category/product/Wine?id=33
我創建的規則是:
RewriteCond %{HTTP_HOST} ^(.*)example\.com\.br$
RewriteCond %{REQUEST_URI} ^(.*)category/product/(.*)$
RewriteRule ^(.*)$ http://www.mynewsite.com.br/category/product/luxe-product/$1? [R=301,L]
預期重寫爲:
1)www.mynewsite.com.br/category/product/luxe-product/Beer
2) www.mynewsite.com.br/category/product/luxe-product/Wine
但是,使用這種規則的輸出網址是:
1)www.mynewsite.com.br/category/product/luxe-product/category/product/Beer
2)www.mynewsite.com.br/category/product/luxe-product/category/product/Wine
在這種情況下,由於我無法使用$ 0,$ 1和$ 2指令分開,因此我幾乎不在輸出中放入類別/產品。任何人都有一個想法如何解決這個問題?
問候,
工作!我懷疑,我的錯誤是在RewriteRule中使用(。*),對嗎?我還不瞭解這部分規則。我需要學習更多。你能建議一個好的教程嗎?感謝和最好的問候。 – Folley 2014-10-05 14:51:26