M
M
Maxim2014-04-21 13:00:14
Yii
Maxim, 2014-04-21 13:00:14

How to write a rule for cUrlManager taking into account site localization?

The site is written on yii framework 1.11. There are several language versions, all of them are located on subdomains, for example:
en.site.com
ua.site.com
And for subdomains there is a rule in .htaccess

RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.site\.com$ [NC]
RewriteRule (.*) index.php?cn=%2 [NC,QSA]

Where cn is the name of the subdomain. In short, requests go to one script with the GET cn parameter, and mod_rewrite rewrites them to subdomains. Its OK.
The problem is in the urls generated by the cLinkPager pager, it adds cn as a GET parameter, i.e. the link to the second page of the news list looks like this en.site.com/en?page=2 if you click on page1. then the url will change to en.site.com/en?en= . It shouldn't be like this, it should be like this: en.site.com/?page=2 , taking into account other GET sorting parameters, it should be like this
en.site.com/?param1=val1¶m2=val2&page=2
There is a rule in the config
'<cn:\w+>' => 'site/index',
How can I give url to the required format?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lexxtor, 2014-04-21
@go3l337

In my opinion, it is more correct to address all requests to index.php without the GET parameter. And already in Yii to receive it.
In Yii, you can write rules with domains:
Give a list of all rules. Otherwise, it is not clear how everything works for you.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question