i need to know How to forward all url to a single url in yii
all link go to a single url
need this for showing maintenance message
i need to know How to forward all url to a single url in
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Update
The old code sample stopped working since Yii 1.1.16. Thanks to JamesG (see comment) for the new solution. Code sample has been updated.
As you have already figured out,
catchAllRequestis the best way to do this from within yii. It has been made specifically for such cases, as is quite evident from the documentation. Using it could also probably give you a slight performance increase (overurlManager), but i doubt that it’ll be noticeable.On the other hand if you wish to use
urlManager, you can try with (also read comments in code sample):Version 1.1.16 and above:
Version 1.1.15 and below:
Note: This will have to be the first rule in your urlManager’s
rulesarray configuration.However as already mentioned by sl4mmer, htaccess or server configuration is the best way to do this, since the server after all catches the request first before sending it to php.
Note for Bug:
Check github issue here.