×ðÁú¿­Ê±¹ÙÍøµÇ¼

thinkphpÔõôÉèÖ÷ÓÉÆ÷

Ëæ×Å»¥ÁªÍøµÄÆÕ¼°£¬ÍøÕ¾¿ª·¢Ô½À´Ô½Êܵ½¹«¹²µÄ¹Ø×¢¡£ÔÚÍøÕ¾¿ª·¢ÖУ¬Â·ÓÉÆ÷£¨router£©ÊǺÜÖ÷ÒªµÄÒ»¸ö¿´·¨¡£Â·ÓÉÆ÷µÄ×÷ÓÃÊÇƾ֤urlµØµãµÄ²î±ð£¬½«²î±ðµÄÇëÇó·Ö·¢µ½²î±ðµÄ´¦Àí³ÌÐòÖÐÈ¥¡£thinkphpÊÇÒ»¿î¿ªÔ´php¿ò¼Ü£¬ÓкÜÇ¿µÄ¿ØÖÆÆ÷ºÍ·ÓÉÆ÷¹¦Ð§£¬¿ÉÒÔÈÃÎÒÃÇÔ½·¢Àû±ãµØÍê³ÉÍøÕ¾¿ª·¢¡£

ÄÇô£¬ThinkPHPÔõôÉèÖ÷ÓÉÆ÷ÄØ£¿ÔÚ±¾ÎÄÖУ¬ÎÒÃǽ«ÏÈÈÝThinkPHP·ÓÉÆ÷µÄ»ù±¾ÖªÊ¶ºÍÉèÖÃÒªÁì¡£

Ò»¡¢Ê²Ã´ÊÇ·ÓÉÆ÷£¿

ÔÚWeb¿ª·¢ÖУ¬Â·ÓÉÆ÷ÊÇÒ»¸öºÜÊÇÖ÷ÒªµÄ¿´·¨¡£¼òÆÓÀ´Ëµ£¬Â·ÓÉÆ÷¾ÍÊÇÒ»¸öÓÃÀ´×ª·¢ÇëÇóµÄ¿ØÖÆÆ÷£¬Ëü»áƾ֤URLµÄ²î±ð£¬½«ÇëÇóת·¢µ½²î±ðµÄ´¦Àí³ÌÐòÖÐÈ¥¡£¾Ù¸öÀý×Ó£¬À´×Ô¿Í»§¶ËµÄÇëÇó£º

http://www.example.com/user/profile/1

Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡± £»

ÆäÖУ¬/user/profile/1¾ÍÊÇURL¡£ÄÇô·ÓÉÆ÷»áÆÊÎöURL²¢½«Æäת»»Îª¶ÔÓ¦µÄ¿ØÖÆÆ÷Ãû³Æ¡¢ÒªÁìÃû³ÆºÍ²ÎÊý£¬×îÖÕŲÓÃÖ¸¶¨µÄ´¦Àí³ÌÐò¡£

¶þ¡¢ThinkPHP·ÓÉÆ÷µÄ»ù±¾Ó÷¨

ÔÚThinkPHPÖУ¬Â·ÓÉÆ÷ÓÐÁ½ÖÖģʽ£ºPathInfoģʽºÍURLģʽ¡£PathInfoģʽÊÇĬÈÏģʽ£¬ËüʹÓÃÀàËÆÓÚÏÂÃæµÄURL£º

http://www.example.com/index.php/user/profile/id/1

ÆäÖУ¬index.phpÊÇÈë¿ÚÎļþ£¬userÊÇ¿ØÖÆÆ÷Ãû³Æ£¬profileÊÇÒªÁìÃû³Æ£¬idÊDzÎÊýÃû£¬1ÊDzÎÊýÖµ¡£ÔÚPathInfoģʽÏ£¬Â·ÓÉÆ÷»áÆÊÎöURL²¢½«Æäת»»Îª¶ÔÓ¦µÄ¿ØÖÆÆ÷Ãû³Æ¡¢ÒªÁìÃû³ÆºÍ²ÎÊý£¬×îÖÕŲÓÃÖ¸¶¨µÄ´¦Àí³ÌÐò¡£

URLģʽʹÓÃÀàËÆÓÚÏÂÃæµÄURL£º

http://www.example.com/index.php?m=user&a=profile&id=1

ÆäÖУ¬mÌåÏÖÄ£¿éÃû³Æ£¬aÌåÏÖÒªÁìÃû³Æ£¬idÊDzÎÊýÃû£¬1ÊDzÎÊýÖµ¡£ÔÚURLģʽÏ£¬Â·ÓÉÆ÷»áÆÊÎöURL²¢½«Æäת»»Îª¶ÔÓ¦µÄ¿ØÖÆÆ÷Ãû³Æ¡¢ÒªÁìÃû³ÆºÍ²ÎÊý£¬×îÖÕŲÓÃÖ¸¶¨µÄ´¦Àí³ÌÐò¡£

Èý¡¢Â·ÓÉÆ÷µÄÉèÖÃÒªÁì

ÔÚThinkPHP¿ò¼ÜÖУ¬Â·ÓÉÆ÷µÄÉèÖÃÒªÁì½ÏÁ¿¼òÆÓ¡£ÎÒÃÇÖ»ÐèÒªÔÚapplicationconfig.phpÉèÖÃÎļþÖоÙÐÐÉèÖü´¿É¡£

ÏÂÃæÊÇÒ»¸ö»ù±¾µÄ·ÓÉÆ÷ÉèÖÃʾÀý£º

//¿ªÆô·ÓÉ
'URL_ROUTER_ON'   => true, 

//·ÓɹæÔò
'URL_ROUTE_RULES'=>array(
    //·ÓɹæÔò1
    'user/:id'=>'user/profile',
    //·ÓɹæÔò2
    'blog/:year/:month/:day'=>'blog/archive',
),

µÇ¼ºó¸´ÖÆ

ÉÏÃæµÄʾÀýÖУ¬ÎÒÃÇ¿ªÆôÁË·ÓÉ£¬²¢ÉèÖÃÁËÁ½¸ö·ÓɹæÔò¡£µÚÒ»¸ö¹æÔòÌåÏÖµ±»á¼û/user/1ʱ£¬Â·ÓÉÆ÷»á½«ÆäÆÊÎöΪuser¿ØÖÆÆ÷µÄprofileÒªÁ죬²¢½«id²ÎÊýÉèÖÃΪ1¡£µÚ¶þ¸ö¹æÔòÌåÏÖµ±»á¼û/blog/2020/05/31ʱ£¬Â·ÓÉÆ÷»á½«ÆäÆÊÎöΪblog¿ØÖÆÆ÷µÄarchiveÒªÁ죬²¢½«year²ÎÊýÉèÖÃΪ2020£¬month²ÎÊýÉèÖÃΪ05£¬day²ÎÊýÉèÖÃΪ31¡£

ÐèҪעÖصÄÊÇ£¬Â·ÓÉÆ÷µÄ¹æÔòÊÇÓÐÓÅÏȼ¶µÄ£¬½¨Ò齫ÓÅÏȼ¶¸ßµÄ¹æÔòÉèÖÃÔÚÇ°Ãæ¡£

ËÄ¡¢Â·ÓÉÆ÷µÄ¸ß¼¶Ó÷¨

³ýÁË»ù±¾µÄ·ÓÉÆ÷ÉèÖÃÖ®Í⣬ThinkPHP»¹ÌṩÁËÐí¶à¸ß¼¶Â·ÓÉÆ÷ÉèÖã¬Èç·ÓÉÆ÷·Ö×é¡¢¶¯Ì¬Â·ÓÉÆ÷µÈµÈ¡£ÏÂÃæ¼òÆÓÏÈÈÝÒ»ÏÂÕâЩ¸ß¼¶Â·ÓÉÆ÷ÉèÖõÄʹÓÃÒªÁì¡£

1.·ÓÉÆ÷·Ö×é

·ÓÉÆ÷·Ö×éÊǽ«Â·ÓÉÆ÷·Ö³É¶à¸ö×飬ÿ¸ö×éÓи÷×ԵķÓɹæÔò¡£ÏÂÃæÊÇÒ»¸ö·ÓÉÆ÷·Ö×éµÄʾÀý£º

//¿ªÆô·ÓÉ
'URL_ROUTER_ON'   => true, 

//·ÓɹæÔò
'URL_ROUTE_RULES'=>array(
    '[user]'     => array('User/'), 
    '[blog]'     => array('Blog/'),
),

µÇ¼ºó¸´ÖÆ

ÉÏÃæµÄʾÀýÖУ¬ÎÒÃÇÉèÖÃÁËÁ½¸ö·ÓÉÆ÷·Ö×飺userºÍblog¡£Ã¿¸ö·Ö×鶼Óи÷×ԵķÓɹæÔò¡£

2.¶¯Ì¬Â·ÓÉÆ÷

¶¯Ì¬Â·ÓÉÆ÷ÊÇָ·ÓÉÆ÷¹æÔò¿ÉÒÔƾ֤ÇëÇóµÄ²î±ð¶ø¶¯Ì¬¸Ä±ä£¬È磺ƾ֤²î±ðµÄÓïÑÔÏÔʾ²î±ðµÄÒ³Ãæ¡£ÏÂÃæÊÇÒ»¸ö¶¯Ì¬Â·ÓÉÆ÷µÄʾÀý£º

//¿ªÆô·ÓÉ
'URL_ROUTER_ON'   => true, 

//·ÓɹæÔò
'URL_ROUTE_RULES'=>array(
    ':lang/blog/:year/:month/:day'=>'blog/archive',
),

µÇ¼ºó¸´ÖÆ

ÉÏÃæµÄʾÀýÖУ¬ÎÒÃÇÉèÖÃÁËÒ»¸ö¶¯Ì¬Â·ÓÉÆ÷¹æÔò¡£µ±ÇëÇóµÄURLÖаüÀ¨lang²ÎÊýʱ£¬Â·ÓÉÆ÷»áƾ֤lang²ÎÊýµÄ²î±ð¶ø¶¯Ì¬ÆÊÎö·ÓÉÆ÷¹æÔò¡£

×ÛÉÏËùÊö£¬Â·ÓÉÆ÷ÊÇWeb¿ª·¢ÖкÜÊÇÖ÷ÒªµÄÒ»¸ö¿´·¨¡£ThinkPHPÌṩÁËÇ¿Ê¢µÄ·ÓÉÆ÷¹¦Ð§£¬¿ÉÒÔ´ó´ó¼ò»¯ÎÒÃǵĿª·¢ÊÂÇé¡£ÔÚʹÓ÷ÓÉÆ÷µÄÀú³ÌÖУ¬ÎÒÃÇÐèҪƾ֤×Ô¼ºµÄÐèÇó¾ÙÐÐÉèÖú͵÷½â£¬ÒÔ±ãʵÏÖÔ½·¢ÎÞаºÍ¸ßЧµÄÍøÕ¾¿ª·¢¡£

ÒÔÉϾÍÊÇthinkphpÔõôÉèÖ÷ÓÉÆ÷µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±¹ÙÍøµÇ¼ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
ÍøÕ¾µØͼ