.htaccess 查询字符串小问题?
我的 php:
if(isset($_GET['text'])) {
$text = $_GET['text'];
} else {
$text = "default"; //if no ?text= set then print "default"
}
我的 .htaccess
RewriteEngine On
RewriteRule ^(.*)$ index.php?text=$1 [L,QSA]
.htaccess 实际上工作得很好,除非我没有将文本设置为我的网址,否则我的 else 语句(“默认”)不起作用。
所以如果输入 mydomain.com/whatthe 一切正常 ($text = "whatthe";) 然而,当我只是调用 mydomain.com $text 是空的而不是包含“默认”。
我做错了什么?
my php:
if(isset($_GET['text'])) {
$text = $_GET['text'];
} else {
$text = "default"; //if no ?text= set then print "default"
}
my .htaccess
RewriteEngine On
RewriteRule ^(.*)$ index.php?text=$1 [L,QSA]
the .htaccess works actually fine, except if i don't set text to my url my else statement ("default") doesn't work.
so if enter mydomain.com/whatthe everything works fine ($text = "whatthe";)
however when i just call mydomain.com $text is empty instead of cotaining "default".
what do i wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
发生的情况是您仍在设置 GET 变量,尽管设置为 null 或空字符串。
你应该使用:
What is happening is that you are still setting the GET variable, albeit to null or an empty string.
You should use: