.htaccess Wildcard Subdomains

后端 未结 3 1098
终归单人心
终归单人心 2020-12-09 14:04

I\'m trying to implement a solution using .htaccess and wildcard subdomains so that

http://subdomain.example.com is mapped to http://example.com/index.php/accounts/s

3条回答
  •  一整个雨季
    2020-12-09 14:56

    This is an adaptation of the code I use to redirect subdomains on my own site. I make no claims to it being best practice but it works;

    RewriteCond %{HTTP_HOST} ^(.*)\.com$ [NC]
    RewriteCond %1 !^(www)\.example$ [NC]
    RewriteRule ^.*$ http://www.example.com/index.php/accounts/%1/ [R=301,L]
    

提交回复
热议问题