【发布时间】:2014-02-08 17:52:53
【问题描述】:
我已经在寻找这个How to create user profiles with PHP and MySQL 和这个profile username in URL instead of user ID 以及其他。但它仍然不适合我。我当前的url 当用户查看他/她的个人资料时是这样的http://localhost/sn/profile.php?id=1 现在我想要url 是这样的http://localhost/sn/myusername 我知道这可能是重复的但仍然没有任何答案到目前为止为我工作:(有什么帮助吗?提前谢谢。
这是我在.htaccess中尝试过的
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.*)/$ http://localhost/sn/profile.php?id=$1
【问题讨论】:
-
您的 htaccess 在哪里?在您的
sn目录或文档根目录中? -
它与我的
index.php和profile.php一起位于sn文件夹内
标签: php apache .htaccess mod-rewrite