[英]Domain redirect and rewrite with htaccess
If a my site is www.example.com
and a user types in www.example.com/robert
I would like to display the page at www.example.com/users?user=robert
. 如果我的网站是www.example.com
在和用户类型www.example.com/robert
我想在显示页面www.example.com/users?user=robert
。 Basically I want to create a profile page for each user but I want it to be accessible by simply typing the username after the domain as a directory. 基本上,我想为每个用户创建一个配置文件页面,但我希望通过简单地在域后输入用户名作为目录即可访问它。
How can I do this with .htaccess? 我如何用.htaccess做到这一点?
Enable mod_rewrite and .htaccess through httpd.conf
and then put this code in your .htaccess
under DOCUMENT_ROOT
directory: 通过httpd.conf
启用mod_rewrite和.htaccess,然后将此代码放在DOCUMENT_ROOT
目录下的.htaccess
:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+?)/?$ /users.php?user=$1 [L,QSA]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.