重写给我不需要的$ _get参数
我需要video/5
be video.php?id = 5
RewriteRule ^video$ video.php [L]
RewriteRule ^video/([^/]*)/?$ video.php?id=$1 [QSA,NC,L]
高度 - 上述代码工作 - 但这是一个问题:
video/
- 没有ID
- 给我一个空字符串,为$ _ get ['id']
,
因此,如果我编写:
if(ISSET($ _ get ['id ['id']) ))...
- 结果是true
,值是“”
如何避免这种情况?
我只需要视频/
- 没有任何$ _GET变量 - 除非明确设置 - 例如 - video/5
I need video/5
to be video.php?id=5
RewriteRule ^video$ video.php [L]
RewriteRule ^video/([^/]*)/?$ video.php?id=$1 [QSA,NC,L]
esentially - the above code works - but here is a problem:
video/
- without id
- gives me an empty string as $_GET['id']
so if I write:
if(isset($_GET['id']))...
- the result is true
and the value is ""
how to avoid this ?
I want just video/
- without any $_GET variable - except it is set explicitly - for example - video/5
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用您显示的样本,请尝试遵循HTACCESS规则。在测试URL之前,请确保清除浏览器缓存。
With your shown samples, please try following htaccess rules. Make sure to clear your browser cache before testing your URLs.