I'm pretty new to nginx and am trying to setup some pretty simple rewrite rules, but they don't seem to be working.
Just for your info, this server { .. }
has its server_name domain.com *.domain.com
.
I have this rewrite ^ /index.php?/$request_uri;
which seems to work great. This will match domain.com/asd/sad/sad and everything works as it should.
However, i'd like to do something funky with subdomains... so I have s1.domain.com
and s198.domain.com
but I would like to change my rewrite so it goes to /index.php?/s1/$request_uri
if that makes sense? So the subdomain goes in before the $request_uri
.
This is what I have tried so far:
if ($host ~* ^([a-z]+)\..*) {
rewrite ^(.*)$ /index.php?/$1/$request_uri;
}
rewrite ^ /index.php?/$request_uri;
Really appreciate any help you can give!
Thanks.
/index.php?q=$request_uri
, but if this is what works for you...RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} ^dev\..*
RewriteRule ^(.*)$ index.php/dev/$1 [L]