用户名而不是URL中的id [英] Usernames instead of id in URL
本文介绍了用户名而不是URL中的id的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我设置了个人资料页面,以便它是blahblah.com/profile?id=6(等等)
如何设置它以便它是blahblah.com/daveisgreat(等) ?
I have profile pages set up so that it's blahblah.com/profile?id=6 (etc.)
How would i set it up so it's blahblah.com/daveisgreat (etc.) ?
推荐答案
通常完成此操作的软件称为重写引擎:http://en.wikipedia.org/wiki/Rewrite_engine [ ^ ]。
现在,一切都取决于您的HTTP浏览器以及您对其配置的访问权限。找出你有什么(可能使用phpinfo
, http://php.net/phpinfo [ ^ ]),阅读与您的网络托管计划相关的文档,如果您需要,请与您的Web托管服务提供商的客户服务部门联系。
如果您的客户自行托管您的网站,则设置重写引擎不会完全是个问题;只需阅读所使用的HTTP浏览器上的文档。
-SA
The piece of software which usually does exactly this is called rewrite engine: http://en.wikipedia.org/wiki/Rewrite_engine[^].
Now, everything depends on what is your HTTP browser and your access to its configuration. Find out what do you have (perhaps usingphpinfo
, http://php.net/phpinfo[^]), read the documentation relevant to your Web hosting plan and, if you need to, talk to the customer service of your Web hosting provider.
If you your customers self-host your site, setting up a rewrite engine won't be a problem at all; just read the documentation on the HTTP browser used.
—SA
嗨朋友,
我有一个解决方案,考虑到你的服务器或webhost支持重写模块......
Hi Friend,
I have a solution considering your server or webhost supports rewrite module...
# This is the .htaccess file
# You need to append these codes in your .htaccess file
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) index.php/
1 [L]
现在当你完成这个时,下一步就是一个url解析引擎...一个简单的例子如下:
Now when you have done this, the next step is a url parsing engine... a simple example is as follow
/**
* A Simple URL Parsing Engine
**/
require_once CLASS_PATH.'database.php';
require_once CLASS_PATH.'generator.php';
class URIParser {
private
这篇关于用户名而不是URL中的id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文