Q
Q
QuickStudio2012-03-26 20:26:33
CodeIgniter
QuickStudio, 2012-03-26 20:26:33

Rewrite but not normal?

Good afternoon.
There is a need to implement such functionality on CodeIgniter
Imagine there is a controller - partner

class Partner extends CI_Controller {<br>
function page($partnerName,$method = 'main'){<br>
echo $this->$method($partnerName);<br>
}<br><br>
function main($partnerName){<br>
//выводит view<br>
}<br><br>
function contacts($partnerName){<br>
//выводит view<br>
}<br><br>
}<br>

As a result, the following links are obtained:
site.com/partner/page/PartnerName/
site.com/partner/page/PartnerName/contacts/
and the like
Question. How to correctly write the setting in rewrite nginx to get this:
partnerName.site.com/
partnerName.site.com/contacts/
I would be very grateful.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Q
Quadratoff, 2012-03-27
@QuickStudio

try like this:
server {
server_name ~^(www\.)?(?<PARTNER>.+)\.site\.com$;
rewrite ^/(.*)$ http\://site\.com/partner/page/$PARTNER/$1 last;
return 403;
}

L
Lico, 2012-03-27
@Lico

Isn't it easier to define this in application/config/routes.php ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question