Maison  >  Article  >  php教程  >  YII模块实现绑定二级域名的方法,yii二级域名

YII模块实现绑定二级域名的方法,yii二级域名

WBOY
WBOYoriginal
2016-06-13 09:29:131344parcourir

YII模块实现绑定二级域名的方法,yii二级域名

YII模块实现绑定二级域名主要有如下步骤:

首先在配置文件设置:

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

blog 为一个模块 ,如果在blog模块下还存在第二个控制器(这里以comment为例),则需要多写一个规则,如下:

'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),
),

如要访问blog下的某一条评论的URL会是:http://test.jb51.net/comment-1.html

本在地服务器的情况:

一、在YII配置中设置了还不够的,还需要在DNS服务器中把test.jb51.net二级域名解析到程序服务器,可以在hosts中的最后加入

127.0.0.1    www.jb51.net   test.jb51.net

二、还需要在apache服务器的http.conf中添加:

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>

如果需要绑定多个二级域名,则只要重复添加即可.

二级域名绑定问题

你咨询一下你们的主机供应商有,有些主机是不支持子域名的绑定的,还有一个就是检查你程序里面设置是否正确!就这两方面的原因!
正常来说是可以实现你说的要求的!希望对你的问题有所帮助,如果还有什么疑问可以HI在线咨询,IT精英俱乐部真诚为您解答!
吴福东 [权威专家]

yii框架怎配置二级域名

这个你可以摆渡一下
 

Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn