Regex 我的htaccess正则表达式有什么问题?
我想转换这个美丽的URLRegex 我的htaccess正则表达式有什么问题?,regex,.htaccess,mod-rewrite,Regex,.htaccess,Mod Rewrite,我想转换这个美丽的URL 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 但它有一个错误
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);
我将非常感谢任何帮助
重写规则
与域名不匹配。您可以使用:
RewriteEngine On
RewriteRule ^(\d+)/[^/]+/(.*)$ texts.php?nead_id=$1$2 [L,NC]
重写规则
与域名不匹配。您可以使用:
RewriteEngine On
RewriteRule ^(\d+)/[^/]+/(.*)$ texts.php?nead_id=$1$2 [L,NC]
那么这个URL是怎样的:
http://insenti.ru/425/sayt-dlya-odinokih-ne-vybirayut/&page=2
包含&
但没有?
?这个漂亮的url可能包含任何内容。重要的是它是如何转换的。我在转换它时遇到问题。那么这个URL:http://insenti.ru/425/sayt-dlya-odinokih-ne-vybirayut/&page=2
包含&
但没有?
?这个漂亮的url可能包含任何内容。重要的是它是如何转换的。转换时遇到问题。^(\d+)\/(.*)\/(.*)$text.php?nead\u id=$1$3在重写规则中不需要转义正斜杠^(\d+)\/(.*)\/(.*)$text.php?nead\u id=$1$3在重写规则中不需要转义正斜杠