【发布时间】:2012-04-10 01:06:17
【问题描述】:
在我的网站上,可以通过 URL www.example.com/user/profile.php?uid=3 访问用户配置文件
我希望通过简单地请求www.example.com/username 来让用户更轻松地访问他们的个人资料
每个用户都有一个不能更改的用户名。我怎样才能做到这一点?
Here is my current .htaccess file
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
# If the request is not for a valid directory
RewriteCond %{REQUEST_FILENAME} !-d
# If the request is not for a valid file
RewriteCond %{REQUEST_FILENAME} !-f
# If the request is not for a valid link
RewriteCond %{REQUEST_FILENAME} !-l
# finally this is your rewrite rule
RewriteRule ^blog/(.+)$ blog.php/$1 [L,NC]
RewriteRule ^(.+)$ user_page/profile.php?uid=$1 [L,QSA]
【问题讨论】:
标签: php regex apache .htaccess mod-rewrite