注册时生成配置文件页面-PHP [英] Generate Profile Page Upon Registration - PHP
问题描述
可能重复:
在LAMP配置中创建别名URL
Possible Duplicate:
Create vanity URLs in a LAMP configuration
用户注册后,我希望他们选择的用户名用于生成任何人(不仅是用户)都可以查看的唯一个人资料页面.如果"bob"注册,他将在website.com/bob
Once a user registers, I want the username they have chosen to be used to generate a unique profile page viewable to anyone (not just the user). If "bob" registers, he will have a profile at website.com/bob
我已经看过类似的问题,这些问题可以解决.htaccess的问题,但是它们没有描述如何完成此工作.
I have looked at similar questions that say to solve the problem with .htaccess, but they don't describe how this can be done.
推荐答案
注册后,您不需要完全生成唯一的个人资料页面.您可以简单地制作一个像profile.php
这样的脚本,该脚本使用参数user
来访问/profile.php?user=bob
以动态显示给定用户的个人资料.示例:
You wouldn't exactly need to generate a unique profile page upon registration. You can simply make a script like profile.php
which takes a parameter user
to dynamically show the profile of a given user by accessing /profile.php?user=bob
. Example:
<?php
$u = $_GET['user'];
echo "<h2>Profile of ".htmlentities($u)."</h2>";
?>
例如,当您想使用以下内容重写website.com/user/bob
指向website.com/profile.php?user=bob
的URL时,.htaccess就会起作用.
.htaccess comes into play when you want to rewrite the url website.com/user/bob
to point to website.com/profile.php?user=bob
by using the following, for example.
RewriteEngine On
RewriteBase /
RewriteRule ^/user/([0-9a-zA-Z]*)$ /profile.php?user=$1 [NC,QSA,L]
这篇关于注册时生成配置文件页面-PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!