Welcome Guest, Not a member yet? Register   Sign In
How to do subdomains with Codeigniter and Nginx?
#1

[eluser]tim peterson[/eluser]
I'd like to have various subdomains on my site such as this: biology.mysite.com

Currently I have the following code in my nginx.conf:

Code:
server {
      listen 80;
      server_name biology.mysite.com;
      return 301  https://mysite.com/tags/biology$request_uri;
    }

This code works in that if you point the browser to biology.mysite.com, it redirects to mysite.com/tags/biology and the correct biology content loads. However, I don't want to redirect the url but want the subdomain to remain the url.

So instead I replaced the above with the code below based on [this gist][1] but it has no effect (meaning pointing to biology.mysite.com simply goes to mysite.com):

Code:
if ($host ~* ^www\.([a-z0-9]*)\.(mysite\.com) )
          {
              set $tagname $1;
              set $host_without_www $2;
              rewrite ^/(.*)$ $scheme://$tagname.$host_without_www/ permanent;
          }

          if ($host ~* ^([a-z0-9]+)\.(mysite\.com))
          {
              set $tagname $1;
                set $host_without_www $2;

                rewrite ^/$ /index.php/tags/index/ last;
                rewrite ^/(.+)$ /index.php/$1 last;
          }

Thoughts?


[1]: https://gist.github.com/lynxluna/1050850




Theme © iAndrew 2016 - Forum software by © MyBB