我写了.htaccess来重写以下网址:
confirmreg.php
到
http://keralapsctuts.com/confirm-registration.html
和
confirmreg.php?code=nsfoh98fkjsdf90
到
http://keralapsctuts.com/code/62fdd2ac2709877a81ecfd7dde9d2810/confirm-registration.html
.htaccess规则是
RewriteRule confirm-registration\.html$ confirmreg.php [QSA,L]
RewriteRule code/(.*)/confirm-registration\.html$ confirmreg.php?code=$1 [QSA,L]
Echo获取不返回代码的值
echo "Code: ". $_GET['code'];
答案 0 :(得分:1)
改进代码:
RewriteRule ^confirm-registration\.html$ confirmreg.php [QSA,L]
RewriteRule ^code/([0-9a-z]+)/confirm-registration\.html$ confirmreg.php?code=$1 [QSA,L]
给RewriteRule一个开始^
RewriteRule ^
可选地,在您想要的字符中更具体。
code/([0-9a-z]+)/