因此,我想要以下内容:
当用户输入浏览器时:mydomain/user/their_username
我希望该用户能够看到其个人资料页面。配置文件页面是我根目录中的一个名为user.php的页面。user.php文件需要一个变量$user
集。因此,当请求user.php时,URL应为:mydomain / user.php?user = their_username
所以从 mydomain/user/their_username to mydomain/user.php?user=their_username
仅允许用户输入a到z(允许使用大写字母),数字和下划线。其他任何操作都应将它们重定向到错误页面。另外,如果用户在末尾输入斜线,则它们应该没有错误。
我应该在htaccess文件中放什么?
(我正在使用xampp来测试我的代码)
试试这个,让我知道它是否有效
RewriteEngine On
RewriteRule ^user/(.+)[/]?$ user.php?user=$1
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句