How to make a tumblr style profile url

笑着哭i 提交于 2019-12-05 11:01:42

Key solution: wildcard subdomains.

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

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]

where http://username.domain.com/xxx would point to /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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!