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 serverNameVirtualHost *: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.
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]
You can ferry this over