我有XAMPP安装在笔记本电脑与Mod Rewrite激活和运行。我有我的网站上的网页如下:国防部重写在查询的PHP页面
http://localhost/TripMan/staff/studentinfo/2
我怎么会写一个重写规则:
http://localhost/TripMan/staff/viewstudent.php?id=2
我想就这样,当有人访问URL作为它上面显示去做这个?我以前从未使用过这个功能。
感谢
我有XAMPP安装在笔记本电脑与Mod Rewrite激活和运行。我有我的网站上的网页如下:国防部重写在查询的PHP页面
http://localhost/TripMan/staff/studentinfo/2
我怎么会写一个重写规则:
http://localhost/TripMan/staff/viewstudent.php?id=2
我想就这样,当有人访问URL作为它上面显示去做这个?我以前从未使用过这个功能。
感谢
您需要使用.htaccess
文件像这样:
# Turn on the rewrite engine
RewriteEngine On
# Set student rewrite
RewriteRule ^TripMan/staff/studentinfo/([0-9]*)/?$ TripMan/staff/viewstudent.php?id=$2 [NC,QSA]
应该是'RewriteRule ^(/ TripMan/staff/studentinfo /)([0-9] *)$ TripMan/staff/viewstudent.php?id = $ 2 [NC,QSA]'? – symcbean
@symcbean两者都应该工作,仅仅是一个例子:-)将修改 –
尝试搜索上堆栈溢出一点,我很相信你会找到答案。 – regilero