2016-03-08 37 views
1

我想這個美女URL我的htaccess正則表達式有什麼問題?

http://insenti.ru/425/sayt-dlya-odinokih-ne-vybirayut/&page=2 

的轉換爲此

http://insenti.ru/texts.php?nead_id=425&page=2 

所以我在我的htaccess的使用正則表達式:

RewriteRule insenti\.ru\/([0-9]+)\/(.*)\/(.*) insenti.ru/texts.php?nead_id=$1$3 

但它有一個錯誤,該重定向不起作用。

這裏是我的整個htaccess文件:

ErrorDocument 404 http://insenti.ru/search/err=nopage 
RewriteEngine On 
RewriteRule (album|chat|help|index|landing|process_data|search|signup|sympathy|user|userspecs)/(.*) $1.php?$2 
RewriteRule insenti\.ru\/([0-9]+)\/(.*)\/(.*) insenti.ru/texts.php?nead_id=$1$3 
RewriteCond %{HTTP_HOST} !^insenti.ru$ [NC] 
RewriteRule (.*) http://insenti\.ru/$1 [R,L] 

當我檢查使用PHP的preg_replace它,它完美的作品:

$link = preg_replace('/insenti\.ru\/([0-9]+)\/(.*)\/(.*)/i', 'insenti.ru/texts.php?nead_id=$1$3', $link); 

我會感謝這麼多,任何幫助!

+1

那麼這是怎麼網址:HTTP':// insenti.ru/425/SAYT-DLYA-odinokih-NE-vybirayut /&頁= 2'含有'&',但沒有'' ? – anubhava

+0

這個漂亮的網址可能包含任何內容。重要的是它如何轉換。我在轉換時遇到問題。 – Otvazhnii

回答

0

RewriteRule與域名不符。您可以使用:

RewriteEngine On 

RewriteRule ^(\d+)/[^/]+/(.*)$ texts.php?nead_id=$1$2 [L,NC] 
+0

^(\ d +)\ /(。*)\ /(。*)$ texts.php?nead_id = $ 1 $ 3 – Otvazhnii

+0

在重寫規則時,不需要轉義正斜槓 – anubhava

+0

錯誤是使用域名。非常感謝! – Otvazhnii