简体   繁体   English

.htaccess用法重写URL

[英]The usage of .htaccess to re-write the url

I have written .htaccess to rewrite the following urls : 我写了.htaccess来重写以下网址:

confirmreg.php

to

http://keralapsctuts.com/confirm-registration.html

and

 confirmreg.php?code=nsfoh98fkjsdf90

to

http://keralapsctuts.com/code/62fdd2ac2709877a81ecfd7dde9d2810/confirm-registration.html

.htaccess Rule is .htaccess规则为

RewriteRule confirm-registration\.html$ confirmreg.php [QSA,L]
RewriteRule code/(.*)/confirm-registration\.html$ confirmreg.php?code=$1 [QSA,L]

Echo Get not returning the value of the code 回声获取不返回代码的值

echo "Code: ". $_GET['code'];

Improved code: 改进的代码:

RewriteRule ^confirm-registration\.html$ confirmreg.php [QSA,L]
RewriteRule ^code/([0-9a-z]+)/confirm-registration\.html$ confirmreg.php?code=$1 [QSA,L]

Give the RewriteRule a starting ^ 给RewriteRule一个开始^

RewriteRule ^

Optionally, be more specific in the characters you want to except. (可选)更具体地指定要排除的字符。

code/([0-9a-z]+)/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM