开发者

Rewrite folder to subdomain with .htaccess?

开发者 https://www.devze.com 2023-03-20 18:10 出处:网络
I\'m currently building a large scale website that allows each profile page to be it\'s own unique sub-domain. I was wondering how would I do this using an .htaccess and mod_rewrite开发者_如何学Python

I'm currently building a large scale website that allows each profile page to be it's own unique sub-domain. I was wondering how would I do this using an .htaccess and mod_rewrite开发者_如何学Python?

For example:

Turn this: http://example.com/profile/userid into: http://userid.example.com


You can try this, if you are using wildcard DNS:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.example\.com$
RewriteCond %{HTTP_HOST} ^(\w+)\.example\.com$
RewriteRule ^(.*)$ profile/%1/$1 [QSA]
0

精彩评论

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

关注公众号