This article mainly introduces how to bind a second-level domain name to the YII module. For more information, see
This article mainly introduces how to bind a second-level domain name to the YII module. For more information, see
The YII module performs the following steps to bind a second-level domain name:
First, set in the configuration file:
'Urlmanager' => array ('urlformat' => 'path', 'showscriptname' => false, // be sure not to enclose 'urlsuffix '=> '.html' in quotation marks for 'false ', 'rules' => array ('HTTP: // test.jb51.net' => array ('/blog', 'urlsuffix '=> ", 'casesensitive' => false ),),
Blog is a module. If there is still a second controller in the blog module (comment is used as an example here), you need to write one more rule, as shown below:
'Urlmanager' => array ('urlformat' => 'path', 'showscriptname' => false, // be sure not to enclose 'urlsuffix '=> '.html' in quotation marks for 'false ', 'rules' => array ('HTTP: // test.jb51.net' => array ('/blog', 'urlsuffix '=> ", 'casesensitive' => false ), 'http: // test.jb51.net/comment- '=> Array ('/blog/comment/', 'urlsuffix' => '.html ', 'casesensitive' => false ),),
To access a comment in a blog, the URL will be:
Local Server:
I. It is not enough to set up in YII configuration. You also need to resolve the test.jb51.net second-level domain name to the program server in the DNS server. You can add it at the end of hosts.
127.0.0.1 test.jb51.net
2. You also need to add:
NameVirtualHost *: 80 ServerAdmin kane@jb51.netDocumentRoot E:/wamp/www/k1029ServerName test. jb51.netErrorLog logs/test.jb51.net-error_logCustomLog logs/test.jb51.net-access_log common
To bind multiple second-level domain names, you only need to add them again.
,