2016-03-08 27 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

相关问题