PHP 动态文件夹
使用 PHP,如何制作动态文件夹系统,例如 http://website.com/user/UsernameHere/ 显示类似 http://website.com/user.php?name=UsernameHere
这是否需要服务器配置,或者可以使用 PHP 实现吗?
Using PHP, how can you make a dynamic folder system, like http://website.com/user/UsernameHere/ show something like http://website.com/user.php?name=UsernameHere
Does this require server configuration, or is it possible with PHP?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通常,这将依赖于 Web 服务器的一定量的 URL 重写支持,例如 apache 下的某些 mod_rewrite 规则。
无论它是一堆复杂的重写规则,还是只是一个将所有内容重写到 /index.php 的简单规则(让我们用 index.php 解析和解释 URI),都没关系。
但您需要一定量的 Web 服务器配置才能使其正常运行。
Typically this will rely on some amount of URL-rewriting support from the web server, for instance, some mod_rewrite rule under apache.
Whether or not it's a bunch of complicated rewrite rules, or just a simple one that rewrites everything to /index.php (and let's index.php parse and interpret the URI), doesn't matter.
But you'll need some amount of web server configuration to get it going.
有一些技巧可以做到这一点。 几乎可以仅使用 PHP 来清理 URL a>,但最终如果你想摆脱“.php”扩展名,你需要对你的服务器做一些事情。如果是 Apache,您可以使用 .htaccess 文件进行清理。
There's a few techniques for doing this. It's nearly possible to clean up your URLs using just PHP, but ultimately if you want to get rid of the ".php" extension you'll need to do something with your server. If it's Apache you can clean up using the .htaccess file.