开发者

i have a problem in .htacces (vanity url)

开发者 https://www.devze.com 2023-02-15 19:09 出处:网络
i am using RewriteEngine On RewriteCond %{HTTP_HOST} ^http://mywebsite.com/ RewriteRule (.*) http://mywebsite.com//$1 [R=301,L]

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 w开发者_JS百科orking , 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?


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:

RewriteRule ^([a-zA-Z0-9_-]+)$ userOrGroup.php?parameter=$1

and then, userOrGroup.php redirects to either profile.php or groupProfile.php (or whatever your group pages are called), depending on whether the parameter is a user name or a group name.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号