简体   繁体   English

基于登录用户的URL重写

[英]url rewrite based on login user

hi is it possible to make url rewrite based on login user? 嗨,有可能使基于登录用户的url重写吗?

For example if user basikal login, they will see the url at the address bar as http://localhost/test/basikal/index.php . 例如,如果用户使用basikal登录,他们将在地址栏中看到网址为http://localhost/test/basikal/index.php

Meanwhile the actual address is http://localhost/real/index.php 同时,实际地址为http://localhost/real/index.php

I need this because i got user that want the system customize to their profile but i dont want to create multiple copies because it is troublesome to maintain it. 我需要这个,是因为我有想要系统根据其配置文件进行自定义的用户,但是我不想创建多个副本,因为维护起来很麻烦。

Thanks. 谢谢。

There are better ways of doing this; 有更好的方法可以做到这一点; a solid MVC framework will allow you to set custom routes. 可靠的MVC框架将允许您设置自定义路由。

But simply: 但简单地说:

  • Create a rewrite rule that rewrites /app/(.+)?/ to /app/ . 创建一个将/app/(.+)?/重写为/app/的重写规则。
  • On every page view, in php, check the url. 在每个页面视图中,在php中,检查URL。 If it isn't /app/username , redirect user to /app/username/ 如果不是/app/username ,则将/app/username重定向到/app/username/
  • Do not ever use the username in the url for identification purposes, always use the session. 永远不要使用url中的用户名来进行标识,请始终使用会话。

This will give the impression to the user that they have a personalized url. 这将给用户留下他们拥有个性化URL的印象。

This is neither efficient, nor pretty but it will work. 这既没有效率,也没有效果,但是会起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM