简体   繁体   English

使用PHP设置“ mydomain.com/username”的任何简单,整洁的方法吗?

[英]Any easy, noncluttering way to set up “mydomain.com/username” using PHP?

Simply put, when a user wants people to be able to go to their profile, we want them to be able to just say go to mydomain.com/username . 简而言之,当用户希望人们能够访问他们的个人资料时,我们希望他们能够说“转到mydomain.com/username The real user page would be at something like mydomain.com/users/page.php?id=1325 which doesn't really help users. 真正的用户页面将位于mydomain.com/users/page.php?id=1325 ,这实际上并不能帮助用户。

The problem: I've been doing PHP for some time, and have never had the need to do this. 问题:我从事PHP已有一段时间了,从来没有必要这样做。 I don't have a clue where to even start? 我不知道从哪里开始? I wouldn't want to do something as naive as just creating actual folders with redirects in them or something.... 我不想做一些天真的事情,就像创建带有重定向或其他内容的实际文件夹一样。

Can anybody tell me how to go about this in php? 谁能告诉我如何在php中进行此操作?

Y'all are the greatest! 你们都是最伟大的!

Provided you are on an apache server look up .htaccess and mod_rewrite , it all happens outside of PHP. 假设您在apache服务器上查找.htaccessmod_rewrite ,则所有这些操作均在PHP外部进行。

Example for your .htaccess : .htaccess示例:

RewriteEngine on
RewriteRule ^([0-9a-zA-Z]+)([\/]?)$ /user/profile.php?name=$1 [L]

暂无
暂无

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

相关问题 如何使用zend框架获取像mydomain.com/username这样的动态URL - how to get dynamic URL like mydomain.com/username using zend framework 网址重写:将mydomain.com/index.php更改为mydomain.com/home - URL rewriting: Change mydomain.com/index.php to mydomain.com/home 使用PHP / Nginx将cookie域从无域迁移到.mydomain.com - Migrate cookie domain from no domain to .mydomain.com with PHP/Nginx PHP邮件未从mydomain.com发送到Google应用程序电子邮件myname@mydomain.com - PHP mail is not sending from mydomain.com to the google apps email myname@mydomain.com 在Heroku上将app.mydomain.com作为mydomain.com/app运行 - Run app.mydomain.com as mydomain.com/app on Heroku Symfony 为 mydomain.com/parameter 创建路由 - Symfony create routing for mydomain.com/parameter 创建一个自定义的wordpress插件,该插件可以像mydomain.com/mytemplate.php?id=xx这样直接调用 - Create a custom wordpress plugin than can be called directly like mydomain.com/mytemplate.php?id=xx Laravel 4.1使用301永久重定向将所有请求从www.mydomain.com重定向到mydomain.com - Laravel 4.1 Redirect all requests from www.mydomain.com to mydomain.com with 301 permanent redirect 如何在Codeigniter中使用mobiledetect.net将mydomain.com重定向到m.mydomain.com? - How to redirect mydomain.com to m.mydomain.com with mobiledetect.net in codeigniter? .href.replace给我双重域名(http:// localhosthttp://mydomain.com) - .href.replace giving me double domain (http://localhosthttp://mydomain.com)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM