A method of binding two-level domain name by Yii module _php instance

Source: Internet
Author: User

The Yii module implements binding level two domain name basically has the following steps:

First in the configuration file settings:

' Urlmanager ' => array (
' urlformat ' => ' path ',
' Showscriptname ' => false,//note false do not enclose in quotes
' Urlsuffix ' => '. html ',
' rules ' => array (
' http://test.jb51.net ' =>array ('/blog ', ' urlsuffix ' => '), ' CaseSensitive ' =>false),

Blog as a module, if the blog module also exists under the second controller (here to comment as an example), you need to write a rule, as follows:

' Urlmanager ' => array (
' urlformat ' => ' path ',
' Showscriptname ' => false,//note false do not enclose in quotes
' 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 blog under the URL of a comment will be: http://test.jb51.net/comment-1.html

The situation on the ground server:

First, in the Yii configuration is not enough, but also in the DNS server to the Test.jb51.net level two domain name resolution to the program server, you can in the final part of the hosts

127.0.0.1    www.jb51.net   test.jb51.net

Second, also need to add in the http.conf of 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 level two domain names, you can add them repeatedly.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.