简体   繁体   English

社交网络htaccess重定向

[英]Social network htaccess redirect

I'm building a php/mysql website and am facing a little problem, I have profiles in my website whereby a random user profile would have the following example link: www.MyDomain.com/profile.php?username=abc 我正在构建一个php / mysql网站并面临一个小问题,我在我的网站上有个人资料,随机用户个人资料会有以下示例链接:www.MyDomain.com/profile.php?username = abc

What i would like to do, is show something like this in the address bar: www.MyDomain.com/abc 我想做的是在地址栏中显示这样的内容:www.MyDomain.com/abc

Also, if someone types in: www.MyDomain.com/abc, it should take him to "abc"'s profile which in reality is www.MyDomain.com/profile.php?username=abc 此外,如果有人输入:www.MyDomain.com/abc,它应该将他带到“abc”的个人资料,实际上是www.MyDomain.com/profile.php?username=abc

I'm not 100% how to do it with the root / level, but I think this should work: 我不是100%如何用root / level来做,但我认为这应该有效:

RewriteEngine on
RewriteBase /
RewriteRule ^([^/\.]+)/?$ profile.php?username=$1 [L]

There's a real neat site you can use to check your rules. 有一个非常简洁的网站,您可以用来检查您的规则。

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

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