.htaccess - 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
我做错了什么?我的错误在哪里?
谢谢!
解决方案
找到了解决方案:
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]
这样可行!
推荐阅读
- unit-testing - 如何使用 Mocha 和 Vue Test Utils 在 VueJS 中测试计算属性
- java - Eclipse 插件开发初学者
- java - @ManyToOne 中的 JPA @ManyToOne 无法正常工作
- java - 从不同的类调用 jdbc 连接得到“java.lang.ClassNotFoundException:oracle.jdbc.driver.OracleDriver”
- docker - Macos 高山 docker-compose.yml 和 .env
- python - 如何识别多变量时间序列预测模型中每个特征的时间延迟
- batch-file - 在任务计划中运行的批处理文件不起作用
- sql-server - 如何在 SQL Change Automation VSTS 发布插件中将 DriftOptionBlockDataLoss 设置为 false
- angular - 如何使用angular5中的API从gmail导入联系人列表?
- php - 当我需要插入 2 个表格时出现错误