我在 .htacces(虚荣网址)中遇到问题
我正在使用
RewriteEngine On
RewriteCond %{HTTP_HOST} ^http://mywebsite.com/
RewriteRule (.*) http://mywebsite.com//$1 [R=301,L]
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ profile.php?user=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ profile.php?user=$1
它,但我的问题是我希望我的组具有虚荣网址。
现在我的用户得到像这个网站[dot]com/username 这样的虚荣网址。
但我希望我的小组也具有像 website[dot]com/groupname 这样的虚荣网址。
有人可以帮忙吗?
i am using
RewriteEngine On
RewriteCond %{HTTP_HOST} ^http://mywebsite.com/
RewriteRule (.*) http://mywebsite.com//$1 [R=301,L]
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ profile.php?user=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ profile.php?user=$1
it's working , but here my problem is i want my group with vanity url.
right now my user get vanity url like this website[dot]com/username.
But i want my group also with vanity url like website[dot]com/groupname.
can any on help in this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这需要您在 htaccess 中区分什么是用户,什么是组。我认为这不是您的情况的一个选项,因为(我猜)您的用户和组名称将是动态的并存储在某种数据库中。
因此,您必须用 PHP 来解决这个问题。您可以执行如下规则:
然后,
userOrGroup.php
重定向到profile.php
或groupProfile.php
(或者您的组)调用页面),具体取决于参数是用户名还是组名。That would require you to differentiate within htaccess what is a user and what is a group. I don't think that this is an option in your case since (I guess) your user and group names will be dynamic and stored in some kind of DB.
Thus, you'll have to solve the problem in PHP. You could do some rule like this:
and then,
userOrGroup.php
redirects to eitherprofile.php
orgroupProfile.php
(or whatever your group pages are called), depending on whether the parameter is a user name or a group name.