我有一个链接www.example.comwww.example.com/user/username我如何重定向它,以便当有人访问www.example.com/username时,他们得到与使用user相同的东西?
因此这些链接将是相同的页面:
www.example.com/user/username/profile>www.example.com/username/profile
www.example.com/user/username/messages>www.example.com/username/messages
www.example.com/user/username/chats>www.example.com/username/chats
有什么我可以改变的吗?htaccess来实现这个结果?

最佳答案

您可以在站点根目录中使用此规则。htaccess:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(?!user/).+$ user/$0 [L,NC]

10-04 21:59
查看更多