×ðÁú¿­Ê±

thinkphp5.0 ÉèÖÃα¾²Ì¬

Ëæ×Å»¥ÁªÍøÊÖÒÕµÄÒ»Ö±Éú³¤ £¬ÍøÕ¾µÄ´î½¨ºÍά»¤Ô½À´Ô½Àû±ãºÍ¼òÆÓ»¯ £¬ÏÖÔÚÐí¶àÈËÑ¡ÔñʹÓÃphp¿ò¼ÜÈ¥¹¹½¨×Ô¼ºµÄÍøÕ¾ ¡£ÆäÖÐthinkphp×÷Ϊһ¿îphp¿ª·¢¿ò¼Ü £¬ÒѾ­³ÉΪÁËÖÚ¶àphp¿ª·¢ÕßµÄÊ×Ñ¡ ¡£ÔÚthinkphp5.0°æ±¾ÖÐ £¬ÉèÖÃα¾²Ì¬ÊǺܻù´¡È´ÓÖ³£¼ûµÄÒ»ÏîÊÂÇé £¬±¾ÆªÎÄÕ½«Îª¶ÁÕßÏÈÈÝthinkphp5.0ÔõÑùÉèÖÃα¾²Ì¬ ¡£

Ò»¡¢Î±¾²Ì¬µÄ¿´·¨

α¾²Ì¬ÊÇÖ¸½«´ø²ÎÊýµÄURLת»¯Îª¶ÔËÑË÷ÒýÇæ¸üÓѺõÄÐÎʽ £¬ÔÚ²»¸Ä±äÒ³Ã涯̬ÌìÉúµÄÇéÐÎϾ²Ì¬Õ¹Ê¾ £¬ÊµÏÖ¶¯Ì¬Ò³ÃæµÄ¾²Ì¬»á¼û ¡£

¾Ù¸öÀý×Ó £¬ºÃ±ÈÒ»¸ö¹Å°åµÄ¶¯Ì¬URLÁ´½ÓΪ£ºhttp://www.example.com/index.php?cat_id=1  £¬½«Æäαװ³É/static/1.html ¡£Õâ¸öʱ¼ä £¬µ±»á¼ûhttp://www.example.com/static/1.htmlʱ £¬Ò³ÃæЧ¹ûÓë»á¼ûhttp://www.example.com/index.php?cat_id=1ÊÇÒ»ÖµÄ £¬¿ÉÊÇÇ°Õ߸üÓѺÃһЩ ¡£

ThinkPHP5.0¿ò¼Ü×Ô¼º¾ÍÖ§³ÖURLα¾²Ì¬ £¬¿ÉÒÔ¸üºÃµØ± £»¤Õ¾µãÇå¾² £¬Í¬Ê±Ò²ÓÐÀûÓÚÌá¸ß×ÔÈ»ËÑË÷µÄÅÅÃû ¡£

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

¶þ¡¢Î±¾²Ì¬µÄÉèÖÃ

ÔÚThinkPHP5.0¿ò¼ÜÖÐ £¬ÊµÏÖURLα¾²Ì¬ÐèÒª¾ÙÐÐÈçÏÂÁ½¸ö°ì·¨£º

ÐÞ¸ÄÉèÖÃÎļþ

·­¿ªÏîÄ¿¸ùĿ¼ÏµÄconfigĿ¼ £¬ÕÒµ½¶ÔÓ¦µÄÎļþ£º

app.php Îļþ£ºÐ޸ġ®url_html_suffix¡®Öµ £¬½«ÆäÉèÖóÉÎÒÃÇÏëÒªµÄºó׺Ãû £¬ÀýÈç.html ¡£

·ÓÉÉèÖÃÎļþ route.php: ÐÞ¸Ä ‘route_config_file’ => ‘route’,

'url_route_on'              =>  true,    //¿ªÆô·ÓÉ
'url_route_must'            =>  true,     //ËùÓзÓɱØÐèÔÚ·ÓɱíÖнç˵

µÇ¼ºó¸´ÖÆ

ÆäÖÐurl_route_mustÉèÖÃΪtrue £¬ÕâÀïÉèÖÃÊÇΪÁË°ü¹ÜËùÓеÄ·Óɶ¼±ØÐèÔÚ·ÓɱíÖнç˵ £¬ÈôÊÇûÓнç˵µÄ»°¾Í»áÅ׳ö404¹ýʧ ¡£

»¹ÐèÒªÔÚroute.phpÎļþÖÐÌí¼Ó·ÓɹæÔò:

// ÉèÖ÷ÓɹæÔò

use thinkRoute;

Route::rule(‘detail- – ‘, ‘index/article/detail’);

ÔÚÉÏÃæµÄ´úÂëƬ¶ÏÖÐ £¬ÎÒÃǽç˵ÁËÒ»¸ö·ÓɹæÔò £¬½«http://www.example.com/index/article/detail/id/1 ת»»Îª http://www.example.com/detail-1.php ¡£ÆäÖÐ £¬detail- – ÊǿɱäµÄ·ÓɹæÔòÃûÌà £¬ ºÍ »®·ÖÊDZäÁ¿Ãû ¡£Í¨¹ýÕâ¸ö·ÓɹæÔò £¬ÎÒÃǽ«ÎÄÕµÄÏêÇéÒ³¶¯Ì¬URLÖØдΪ¾²Ì¬µÄURL ¡£

ÉèÖÃWebЧÀÍÆ÷

ÈôÊÇÏëÈÃÉèÖõÄα¾²Ì¬Â·ÓÉÉúЧ £¬»¹ÐèÒªÔÚWebЧÀÍÆ÷ÉϾÙÐÐÏìÓ¦µÄÉèÖà ¡£ÒÔ Apache ЧÀÍÆ÷ΪÀý £¬ÐèÒªÔÚ Apache µÄÉèÖÃÎļþ .htaccess ÖÐÌí¼Ó´úÂ룺

¿ªÆô RewriteEngine

RewriteEngine On

½ç˵α¾²Ì¬Â·ÓɹæÔò

RewriteRule ^detail-(d+)-(.*)$ /index/article/detail/id/$1 [NC,L]

ÉÏÊö´úÂëʵÏÖÁËÈôÊÇURLÁ´½ÓÆ¥ÅäÁË/detail- – Õâ¶Î·ÓɹæÔòµÄ»° £¬ApacheЧÀÍÆ÷»á½«Á´½Óת·¢µ½/index/article/detail/id/ ´¦, ÆäÖÐ ¾ÍÊÇURLÁ´½ÓÖеÄÊý×Ö²¿·Ö ¡£

Èý¡¢²âÊÔα¾²Ì¬¹¦Ð§

¾ÙÐÐÍêα¾²Ì¬ÉèÖÃÖ®ºó £¬ÐèÒª¶ÔÉèÖõÄα¾²Ì¬¹æÔò¾ÙÐвâÊÔ £¬Ö»ÓÐÔÚ²âÊÔûÎÊÌâÒÔºó²Å»ª°²Åŵ½ÏßÉÏÇéÐÎÖÐ ¡£ÔÚ²âÊÔα¾²Ì¬Ê± £¬ÐèÒªÔÚURLÖмÓÉÏα¾²Ì¬ºó׺ £¬ÀýÈ磺http://www.example.com/detail-1.html £¬ÈôÊǸÃÁ´½ÓÄÜÕý³£»á¼û £¬²¢ÇÒÊÇÖ¸Ïò¶¯Ì¬Ò³ÃæµÄ £¬ÄÇô˵Ã÷α¾²Ì¬ÉèÖÃÀÖ³ÉÁË ¡£

ËÄ¡¢×ܽá

ThinkPHP5.0¿ò¼Ü×Ô´øα¾²Ì¬¹¦Ð§ £¬½èÖúÓÚWebЧÀÍÆ÷µÄÖØд»úÖÆ £¬ÅäºÏÉÏ¿ò¼Ü×Ô¼ºÄÚÖõÄ·ÓÉϵͳºÍÌìÉúURLµÄº¯Êý £¬Äܹ»ÊµÏÖ¿ìËÙµÄα¾²Ì¬ÉèÖà ¡£µ«ÔÚÏÖʵӦÓÃÖÐ £¬»¹ÐèҪ˼Á¿µ½SEOÓѺÃÐÔ¡¢URL¹æ·¶µÈÖڶ෽ÃæµÄÏÞÖÆ £¬ÐèÒªÎÞаÔËÓÃα¾²Ì¬¼Æ»® ¡£

ÒÔÉϾÍÊDZ¾ÎÄÏÈÈݵÄthinkphp5.0ÉèÖÃα¾²Ì¬µÄÒªÁì £¬Ëæ×ÅÊÖÒÕµÄÉú³¤ £¬Î±¾²Ì¬ÒѳÉΪÍøÕ¾½¨ÉèµÄ»ù±¾ÉèÖÃÏîÖ®Ò» £¬ÏàʶÆäÉñÔÏ £¬½«¶ÔÍøÕ¾µÄSEOÓѺÃÐÔºÍÓû§ÌåÑéÓÐËùÌáÉý ¡£

ÒÔÉϾÍÊÇthinkphp5.0 ÉèÖÃα¾²Ì¬µÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±

18523999891

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

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

QR code
¡¾ÍøÕ¾µØͼ¡¿¡¾sitemap¡¿