重写文件夹,子站点的.htaccess?重写、文件夹、站点、htaccess

2023-09-02 20:34:40 作者:睫毛上の泪

我目前正在建设一个大型网站,让每一个资料页是它自己独特的子域。我不知道我将如何使用这一个.htaccess和mod_rewrite的怎么样?

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?

例如:

启用此: http://example.com/profile/userid 成: http://userid.example.com

推荐答案

可以,如果你使用的是通配符的DNS试试这个,:

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]