如何制作Tumblr样式的个人资料网址 [英] How to make a tumblr style profile url

查看:82
本文介绍了如何制作Tumblr样式的个人资料网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道,tumblr怎么做这样的个人资料网址:

I wonder, how does tumblr doing profile url like this:

http://www.username.tumblr.com/ 
http://username.tumblr.com/

我知道我们可以更改个人资料网址

I know we can change the profile url

http://www.website.com/profile.php?user=username

http://www.website.com/username

使用以下RewriteRule

RewriteRule ^([^/]+)/?$ profile.php?user=$1 [L,QSA,NC]

我不知道如何使用这些个人资料网址.

I don't know how tumblr doing those profile urls.

我们如何制作这样的用户个人资料网址:

How can we make user profile urls like this:

http://www.username.website.com/
http://username.website.com/

我有一个VirtualHost.

I have a VirtualHost.

推荐答案

关键解决方案:通配符子域.

这使您可以将*.domain.com指向服务器.

This allows you to make *.domain.com point to your server.

在您的示例中,假设我们为domain.com启用了通配符子域,并且我们想提供用户子域,例如http://username.domain.com.你会有这样的东西:

From your example, let's say we enabled wildcard subdomains for domain.com and we want to provide user subdomains, such as http://username.domain.com. You'd have something like this:

RewriteCond %{HTTP_HOST} ^((?!www.)[^.]+)\.domain\.com$ [NC]
RewriteRule ^(.*)$ /%1/$1 [L]

其中http://username.domain.com/xxx指向/username/xxx.

请注意,为解释起见,已尽可能简化和简化此示例.根据您的上下文,您可能需要其他规则来处理主域和其他条件.

Note that this example has been reduced and simplified as much as possible for the explanation. You'd maybe need other rules, depending on your context, to handle main domain and other conditions.

这篇关于如何制作Tumblr样式的个人资料网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆