Home  >  Article  >  Backend Development  >  YII module implements the method of binding second-level domain name, yii second-level domain name_PHP tutorial

YII module implements the method of binding second-level domain name, yii second-level domain name_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:23:191075browse

YII module implements the method of binding second-level domain name, yii second-level domain name

The YII module implements the following steps to bind a second-level domain name:

First set in the configuration file:

'urlManager' => array(
'urlFormat' => 'path',
'showScriptName' => false, //注意false不要用引号括上
'urlSuffix' => '.html',
'rules' => array(
'http://test.jb51.net'=>array('/blog', 'urlSuffix'=>”, 'caseSensitive'=>false),
),

Blog is a module. If there is a second controller under the blog module (take comment as an example here), you need to write one more rule, as follows:

'urlManager' => array(
'urlFormat' => 'path',
'showScriptName' => false, //注意false不要用引号括上
'urlSuffix' => '.html',
'rules' => array(
'http://test.jb51.net'=>array('/blog', 'urlSuffix'=>”, 'caseSensitive'=>false),
'http://test.jb51.net/comment-<id:\w+>'=>array('/blog/comment/', 'urlSuffix'=>'.html', 'caseSensitive'=>false),
),

If you want to access a comment under the blog, the URL will be: http://test.jb51.net/comment-1.html

The situation of this local server:

1. Setting it in the YII configuration is not enough. You also need to resolve the test.jb51.net secondary domain name to the program server in the DNS server. You can add

at the end of hosts.
127.0.0.1    www.jb51.net   test.jb51.net

2. You also need to add:

to the http.conf of the apache server
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin kane@jb51.net
DocumentRoot E:/wamp/www/k1029
ServerName test.jb51.net
ErrorLog logs/test.jb51.net-error_log
CustomLog logs/test.jb51.net-access_log common
</VirtualHost>

If you need to bind multiple second-level domain names, just add them repeatedly.

Second-level domain name binding issue

Consult your hosting provider. Some hosts do not support subdomain binding. Another way is to check whether the settings in your program are correct! For these two reasons!
Normally speaking, the requirements you mentioned can be achieved! I hope it will be helpful to your question. If you still have any questions, you can consult HI online. The IT Elite Club will sincerely answer your questions!
Wu Fudong [authoritative expert]

How to configure the second-level domain name in yii framework

You can ferry this over

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/840744.htmlTechArticleThe YII module realizes the method of binding the second-level domain name, and the yii second-level domain name YII module realizes the main method of binding the second-level domain name There are the following steps: First set in the configuration file: 'urlManager' = array('urlForma...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn