将带有ID的.php URL改为.html [英] Change .php URL with id into .html
本文介绍了将带有ID的.php URL改为.html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
给定PHP URL course.php?id = 10
我希望它重定向到 course.html
和我想在此页面上使用 id = 10
。我怎样才能做到这一点?
Given the PHP URL course.php?id=10
I want it to redirect to course.html
and I want to use the id=10
on this page. How can I do this?
推荐答案
您无法干净地重写url并且不在某处包含变量。你需要做这样的事情:
You can't cleanly rewrite the url and not include the variable somewhere. You'll need to do something like so:
RewriteRule ^([0-9]+)/([^.]+)\.html $2.php?id=$1 [L]
code> http://example.com/10/course.html 。
Which will work for http://example.com/10/course.html
.
这篇关于将带有ID的.php URL改为.html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文