首页 > 解决方案 > htaccess:用几个变量重写

问题描述

我想重定向一个页面

/topic/italian-page2.html/index.php?s=italien$p=2

或者

/topic/france-page4.html/index.php?s=france$p=4

而且(没有页码)

/topic/spain.html/index.php?s=spain$p=1

现在我用

RewriteRule ^topic/([a-zA-Z0-9\-]+).html$ /index.php?s=$1&p=1 [L]
RewriteRule ^topic/([a-zA-Z0-9\-]+)-page([0-9]+).html$ /index.php?s=$1&p=$2 [L]

第一个(没有页面)工作正常。第二个没有。

它重定向到/index.php?s=italian-page2&p=$2

我做错了什么?我的错误在哪里?

谢谢!

标签: .htaccessredirect

解决方案


找到了解决方案:

RewriteRule ^topic/([a-zA-Z0-9]*)-page([0-9]*).html$  /?s=$1&p=$2 [L]
RewriteRule ^topic/([a-zA-Z0-9\-]+).html$ /?s=$1&p=1 [L]

这样可行!


推荐阅读