2015-01-26 79 views
0

我正在將我的頭撞向牆壁。我創建了一個網站的更新版本,並且我有通過PHP提供的各種動態頁面。舊的頁面通過htaccess的有以下重寫他們:在htaccess中將動態鏈接重定向到新的動態url

舊的URL,然後重寫:REWRITE

/directorio_hoteles/ean/hotel.php?cou=$1&hn=$2&city2=$3 

舊的URL後:

/directorio_hoteles/Mexico/hotel336813/Villa_Mercedes_Petit_Hotel.htm 

這裏是它是如何編碼在原始的.htaccess :

RewriteRule ^([^/]*)/hotel([^/]*)/([^/]*)\.htm$ ean/hotel.php?cou=$1&hn=$2&city2=$3 [L] 

據我所知,這種原始格式不是交流的最佳方式完成這一點,但這是我必須與之合作,並且動態網址已經在谷歌索引。所以,我需要採取上面已經重寫URL和重定向(301)到新的動態格式是:

新的URL,然後重寫:REWRITE

directorio-hoteles/index.php?p=hotel-page&a=$1&b=$2&c=$3 

新的URL後:

directorio-hoteles/hotel/Mexico/Villa_Mercedes_Petit_Hotel/336813 

這裏是它是如何編碼在新htaccess文件:

RewriteRule ^directorio-hoteles/hotel/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)?$  directorio-hoteles/index.php?p=hotel-page&a=$1&b=$2&c=$3 [NC,L] 

所以我不能不要蜘蛛包裹我的頭d如何得到這個:

/directorio_hoteles/Mexico/hotel336813/Villa_Mercedes_Petit_Hotel.htm 

重定向到這樣的:

directorio-hoteles/hotel/Mexico/Villa_Mercedes_Petit_Hotel/336813 

任何幫助將BEYOND讚賞。提前感謝您解決此問題的任何嘗試。

回答

0

您可以在DOCUMENT_ROOT/.htaccess文件中使用此規則爲第一條規則

RewriteEngine On 

RewriteRule ^(directorio_hoteles)/([^/]+)/(hotel)([^/]+)/([^.]+)\.htm$ /$1/$3/$2/$5/$4 [L,NC,NE,R=302]