【问题标题】:How to make RewriteRule?如何制作 RewriteRule?
【发布时间】:2021-12-29 09:51:12
【问题描述】:

我们有 studentPage.php 文件,它显示了学生的信息

我希望 RewriteRule 做到这一点:

example.com/students/John-3

形成这个:

example.com/studentPage.php?name=John&id=3

【问题讨论】:

标签: .htaccess mod-rewrite


【解决方案1】:
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule (students)/([0-9]+)-([a-zA-Z-]+)$ student.php?name=$3&id=$2

【讨论】:

  • 可以摆脱students上的组,然后可以使用参考1和2。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2023-03-07
  • 1970-01-01
  • 1970-01-01
  • 2023-04-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多