将用户名直接添加到URL PHP [英] Directly adding username to URL PHP

查看:89
本文介绍了将用户名直接添加到URL PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何能够将用户名直接附加到网站网址,而不必将其放在查询中吗?

I would to know how one is able to append a username directly to a site url without having to put it within a query?

例如

www.myspace.com/micheal

www.myspace.com/micheal

代替

www.myspace.com?name=米歇尔

www.myspace.com?name=micheal

无需为用户创建新文件夹,以便在键入包含名称的URL时,将直接将冲浪者带入用户的个人资料.

Without having to create a new folder for the user so that when the url is typed including the name, the surfer is taken directly to the user's profile.

感谢

推荐答案

对于Apache Web服务器.htaccess文件,使用以下代码即可完成该工作.

For the Apache web-server .htaccess file with the following code will do the thing.

RewriteEngine on
RewriteBase /
RewriteCond  %{REQUEST_FILENAME} !-f
RewriteCond  %{REQUEST_FILENAME} !-d
RewriteRule  ^(.*)$ index.php?name=$1 [QSA,L]

这篇关于将用户名直接添加到URL PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆