thinkphpÍø̨·¾¶ÔõÑùÉèÖÃ
Ò»¡¢Ê²Ã´ÊÇÍø̨·¾¶
Íø̨·¾¶ÊÇÖ¸WebЧÀÍÆ÷ÉϵÄÐéÄâ·¾¶£¬ËüÓëÎļþϵͳ·¾¶²î±ð¡£ÎªÈ·±£³ÌÐòÕý³£ÔËÐУ¬ÎÒÃÇÐèҪ˼Á¿Ä¿½ñϵͳÇéÐαäÁ¿¡¢²Ù×÷ϵͳµÈÒòËØ£¬²¢ÏìÓ¦µØÉèÖÃÍø̨·¾¶¡£
¶þ¡¢Íø̨·¾¶µÄ×÷ÓÃ
Íø̨·¾¶ÔÚThinkPHP¿ò¼ÜÖÐÓÐ×ÅÖ÷ÒªµÄ×÷Óá£Í¨¹ýÉ趨Íøվ·¾¶£¬ÎÒÃÇ¿ÉÒÔʵÏÖ¶ÔWebÓ¦ÓóÌÐòµÄ»á¼û¿ØÖƺÍÍøÕ¾Êý¾ÝÖÎÀíµÈ¹¦Ð§¡£
Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»
Èý¡¢ThinkPHPÍø̨·¾¶µÄÉèÖÃÒªÁì
1¡¢µÚÒ»ÖÖÒªÁì
ÔÚconfig.phpÎļþÖÐÌí¼ÓÒÔÏ´úÂ룺
'domain' => [ 'www.test.com' => '/home/test/www', ],
µÇ¼ºó¸´ÖÆ
ÔÚÕâ¸öʾÀýÖУ¬ÎÒÃÇÉèÖÃÁËÒ»¸öÃûΪ¡°www.test.com¡±µÄÍøÕ¾ÓòÃû£¬¸ÃÓòÃûµÄ¸ùĿ¼Ϊ¡°/home/test/www¡±¡£ÈôÊÇ´ËʱÎÒÃÇ»á¼ûÍøÕ¾¡°www.test.com¡±£¬ÏµÍ³¾Í»á×Ô¶¯½«ÆäÓ³Éäµ½¡°/home/test/www¡±Ä¿Â¼Ï¡£
2¡¢µÚ¶þÖÖÒªÁì
ÔÚÍøÕ¾¸ùĿ¼Ï£¬ÎÒÃÇ¿ÉÒÔн¨Ò»¸ö.htaccessÎļþ£¬ÆäÖÐÌí¼ÓÒÔÏ´úÂ룺
RewriteEngine on RewriteCond %{REQUEST_URI} !^/index\.php RewriteRule ^(.*)$ /index.php/$1 [L]
µÇ¼ºó¸´ÖÆ
ÕâÑù¾Í¿ÉÒÔ½«ËùÓÐÇëÇó¶¼Ó³Éäµ½index.phpÎļþÖУ¬²¢ÇÒ×Ô¶¯½«URL²ÎÊý×÷Ϊº¯Êý²ÎÊýת´ï¸øindex.phpÎļþ¡£
ÒÔÉÏÁ½ÖÖÒªÁ춼¿ÉÒÔʵÏÖÍø̨·¾¶µÄÉèÖã¬ÎÒÃÇ¿ÉÒÔƾ֤ÏêϸµÄÇéÐÎÑ¡ÔñÏìÓ¦µÄʵÏÖ·½·¨¡£
ËÄ¡¢Íø̨·¾¶µÄʹÓÃ
ÉèÖÃÁËÍø̨·¾¶ºó£¬ÎÒÃǾͿÉÒÔÔÚ³ÌÐòÖÐʹÓÃÄ¿½ñÍøÕ¾µÄ¸ùĿ¼ÁË¡£ÔÚ³ÌÐòÖУ¬ÎÒÃÇ¿ÉÒÔÓó£Á¿¡°__ROOT__¡±À´´ú±íÍøÕ¾µÄ¸ùĿ¼¡£
ÔÚ¿ØÖÆÆ÷ÎļþÖУ¬ÎÒÃÇ¿ÉÒÔÕâÑùʹÓãº
<?php namespace Home\Controller; use Think\Controller; class IndexController extends Controller { public function index(){ $this->display(__ROOT__.'/index.html'); } }
µÇ¼ºó¸´ÖÆ
ÔÚÊÓͼÎļþÖУ¬ÎÒÃÇ¿ÉÒÔÕâÑùʹÓãº
<script src="__ROOT__/public/jquery.js"></script>
µÇ¼ºó¸´ÖÆ
ÒÔÉÏ´úÂ뽫×Ô¶¯Ê¶±ðÄ¿½ñÍøÕ¾µÄ¸ùĿ¼£¬²¢½«ÏìÓ¦µÄÎļþÓ³Éäµ½WebЧÀÍÆ÷µÄÐéÄâ·¾¶ÖС£
ÒÔÉϾÍÊÇthinkphpÍø̨·¾¶ÔõÑùÉèÖõÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡