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

thinkPHP5ÖÐÔõôÒþ²ØÈë¿ÚÎļþ

Ò»¡¢ÇéÐÎ×¼±¸

ÔÚ¾ÙÐÐURLÒþ²Ø֮ǰ  £¬ÎÒÃÇÐèÒªÏȼì²éÒ»ÏÂÍâµØÇéÐÎÊÇ·ñÖ§³Öα¾²Ì¬¹¦Ð§ºÍURLÖØд¹¦Ð§  £¬ÕâÑù²Å»ªË³Ëì¾ÙÐÐURLÒþ²Ø²Ù×÷¡£Ê×ÏÈÎÒÃÇҪȷ±£×°ÖÃÁËApache»òÕßNginxµÈwebЧÀÍÆ÷  £¬È»ºóÔÚÉèÖÃÎļþÖÐÆôÓÃα¾²Ì¬ºÍURLÖØд¹¦Ð§  £¬ÕâÑù²Å»ªÊ¹µÃ¿ò¼Üʶ±ðÌìÉúÃÀ»¯ºóµÄURL¡£

¶þ¡¢¿ªÆôURLÒþ²Ø

·­¿ªÉèÖÃÎļþ

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

ÔÚthinkPHP5µÄÉèÖÃÎļþÖÐ  £¬ÕÒµ½app.phpÎļþ  £¬ÕÒµ½url_html_suffixÉèÖÃÏî  £¬½«ÆäÉèÖÃΪ¿Õ×Ö·û´®  £¬¼´£º

'url_html_suffix'  =>  ''

µÇ¼ºó¸´ÖÆ

ÕâÑù¾ÍÔÊÐíURL²»´øºó׺ÁË¡£

ÉèÖ÷ÓÉ

ͨ¹ýÔÚthinkphp5ÖÐÉèÖ÷ÓɹæÔò  £¬»á¼ûURL¿ÉÒÔÓ³Éäµ½ÏìÓ¦µÄ¿ØÖÆÆ÷»ò²Ù×÷ÒªÁì¡£ÎÒÃÇÐèÒªÕë¶Ôÿ¸ö¿ØÖÆÆ÷»ò²Ù×÷ÒªÁì¾ÙÐжÔÓ¦µÄ·ÓÉÉèÖà  £¬½«Æä¶ÔÓ¦µÄURLÓ³Éäµ½Ò»¸öÓÐÒâÒåµÄÄÚÈÝÉÏ  £¬ÕâÑù²Å»ªÊ¹µÃÒþ²ØµÄЧ¹ûÊ©Õ¹³öÀ´  £¬ÀýÈ磺

Route::get('news/:id','index/index/news',[],['id'=>'\d+']);

µÇ¼ºó¸´ÖÆ

ÕâÑù  £¬»á¼û/news/1Õâ¸öURLʱ  £¬¾Í»á×Ô¶¯Å²ÓÃindex¿ØÖÆÆ÷µÄnews²Ù×÷ÒªÁì  £¬²¢½«ÇëÇó²ÎÊýidÉèÖÃΪ1¡£

ÉèÖÃЧÀÍÆ÷

ÔÚApache»òÕßNginxÖÐÒ²Òª¾ÙÐÐÏìÓ¦µÄÉèÖá£ÒÔApacheΪÀý  £¬ÔÚ.htaccessÖÐÌí¼ÓÒÔÏÂÄÚÈÝ£º

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?s=/$1 [QSA,PT,L]

µÇ¼ºó¸´ÖÆ

Õâ¶Î´úÂëÖÐ  £¬RewriteEngine onÊÇ¿ªÆôApacheµÄURLÖØд¹¦Ð§£»RewriteCond %{REQUEST_FILENAME} !-dºÍRewriteCond %{REQUEST_FILENAME} !-fÊÇɨ³ýµô»á¼ûÎļþºÍĿ¼µÄÇëÇó  £¬×èÖ¹¶Ô¾²Ì¬×ÊÔ´µÄ»á¼ûÔì³ÉÓ°Ï죻×îºóRewriteRuleÓÃÓÚ½«URLÖ¸ÏòthinkPHPÈë¿ÚÎļþindex.php  £¬²¢´øÉÏ·ÓÉÐÅÏ¢¡£

Èý¡¢¸½¼Ó¹¦Ð§

ÉèÖÃURLºó׺

ÎÒÃÇ¿ÉÒÔͨ¹ýÉèÖÃURLºó׺½øÒ»²½ÔöÇ¿Ó¦ÓõÄÇå¾²ÐÔ¡£ÀýÈç  £¬¿ÉÒÔ½«ËùÓеÄURLºó׺ÉèÖóÉ.shtml¡¢.html¡¢.shtmlµÈ  £¬ÕâÑù¿ÉÒÔÓÐÓÃ×èÖ¹¶ÔÎÒÃǵÄÓ¦ÓÃÔì³É¹¥»÷¡£

¿ÉÒÔÔÚÉèÖÃÎļþÖÐ  £¬ÕÒµ½url_html_suffixÑ¡Ïî²¢¼ÓÉÏÏìÓ¦µÄºó׺¼´¿É  £¬ÀýÈ磺

'url_html_suffix'  =>  'shtml|html|htm'

µÇ¼ºó¸´ÖÆ

×Ô¶¯Ê¶±ðURL

ÔÚRouteÀàµÄregisterÒªÁìÖÐÌí¼ÓÒ»¸ö·ÓɹæÔò  £¬ÒÔ±ã¿ò¼Ü¿ÉÒÔ×Ô¶¯ÆÊÎöURL¡£ÀýÈ磺

if (is_file(APP_PATH . 'route.php')) {
Route::get('/', 'index/index');
Route::get('build', 'index/build');
include_once APP_PATH . 'route.php';
}

µÇ¼ºó¸´ÖÆ

ÕâÑù  £¬ÈôÊÇÓÐÇкϹæÔòµÄURL  £¬½«×Ô¶¯×ª·¢µ½Æä¶ÔÓ¦µÄ¿ØÖÆÆ÷»ò²Ù×÷ÒªÁì¡£

ÒÔÉϾÍÊÇthinkPHP5ÖÐÔõôÒþ²ØÈë¿ÚÎļþµÄÏêϸÄÚÈÝ  £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

QR code
ÍøÕ¾µØͼ