×ðÁú¿­Ê±

laravel5Ôõôȥµôindex.php

laravelÊÇÒ»¿îÊ¢ÐеÄphp¿ò¼Ü £¬ËüÌṩÁËÐí¶à±ãµ±µÄ¹¦Ð§ºÍÇ¿Ê¢µÄÐÔÄÜ £¬ÒÔ×ÊÖú¿ª·¢Ö°Ô±¿ìËÙ¹¹½¨¸ßÖÊÁ¿µÄwebÓ¦ÓóÌÐò¡£È»¶ø £¬ÓÉÓÚĬÈÏÇéÐÎÏÂlaravel¿ò¼ÜʹÓÃÁË´øÓÐindex.phpµÄurl £¬Õâ¿ÉÄÜ»á¶ÔseoºÍÓû§ÌåÑéÔì³É²»Á¼Ó°Ïì¡£±¾ÎĽ«ÏÈÈÝÔõÑùÈ¥µôlaravel5ÖеÄindex.php¡£

ÔÚLaravel5ÖÐ £¬È¥µôindex.phpµÄÒªÁìÓÐÁ½ÖÖ¡£µÚÒ»ÖÖÒªÁìÊÇͨ¹ý.htaccessÎļþ¾ÙÐÐÉèÖà £¬µÚ¶þÖÖÒªÁìÊÇͨ¹ýÐÞ¸ÄLaravelÉèÖÃÎļþ¾ÙÐÐÉèÖ᣽ÓÏÂÀ´ £¬ÎÒÃǽ«ÖðÒ»ÏÈÈÝÕâÁ½ÖÖÒªÁì¡£

1¡¢Í¨¹ý.htaccessÎļþ¾ÙÐÐÉèÖÃ

.htaccessÎļþÊÇÓÃÀ´ÉèÖÃApache WebЧÀÍÆ÷µÄÎļþ¡£Í¨¹ýÐÞ¸Ä.htaccessÎļþ £¬ÎÒÃÇ¿ÉÒÔÖ±½ÓÈ¥µôLaravel5ÖеÄindex.php¡£ÏÂÃæÊÇÏêϸµÄÉèÖð취£º

1.1¡¢ÕÒµ½Laravel5ÏîÄ¿µÄ¸ùĿ¼

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

Ê×ÏÈ £¬ÎÒÃÇÐèÒªÕÒµ½´æ·ÅLaravel5ÏîÄ¿µÄ¸ùĿ¼¡£ÈôÊÇÄúÊÇÔÚÍâµØ´î½¨µÄ¿ª·¢ÇéÐÎ £¬Ôòͨ³£´æ·ÅÔÚWebЧÀÍÆ÷¸ùĿ¼Ï¡£ÈôÊÇÄúÊÇͨ¹ýFTPµÈ¹¤¾ß½«ÏîÄ¿ÉÏ´«µ½Ô¶³ÌЧÀÍÆ÷ £¬ÔòÐèÒªÕÒµ½ÄúÉÏ´«µÄĿ¼¡£

1.2¡¢½¨Éè.htaccessÎļþ

ÔÚÉÏÒ»²½ÕÒµ½µÄĿ¼ÖÐ £¬½¨ÉèÒ»¸öÃûΪ.htaccessµÄÎļþ £¬²¢½«ÒÔÏ´úÂ븴ÖƵ½ÎļþÖУº

<ifmodule>
    RewriteEngine On
    RewriteRule ^(.*)$ public/$1 [L]
</ifmodule>

µÇ¼ºó¸´ÖÆ

ÉÏÊö´úÂëµÄ¼ÄÒåÊÇ£ºÈôÊÇWebЧÀÍÆ÷ÉÏ×°ÖÃÁËmod_rewriteÄ£¿é £¬ÔòÆôÓÃRewriteEngine £¬½«URLÖض¨Ïòµ½publicĿ¼Ï¡£ÕâÑù £¬»á¼ûLaravel5ÏîĿʱ¾Í¿ÉÒÔÖ±½ÓÈ¥µôindex.phpÁË¡£

1.3¡¢ÐÞ¸ÄApacheÉèÖÃÎļþ

ÔÚÈ·±£Ð§ÀÍÆ÷ÉÏ×°ÖÃÁËmod_rewriteÄ£¿éÖ®ºó £¬»¹ÐèÒªÐÞ¸ÄApacheµÄÉèÖÃÎļþ £¬ÒÔÈ·±£.htaccessÎļþ¿ÉÒÔÊ©Õ¹×÷Ó᣷­¿ªApacheÉèÖÃÎļþ£¨Ò»Ñùƽ³£´æ·ÅÔÚ/etc/httpd/conf/httpd.confÖУ© £¬ÕÒµ½ÈçÏÂÉèÖãº

<directory>
    AllowOverride None
    ...
</directory>

µÇ¼ºó¸´ÖÆ

½«ÆäÖеġ°AllowOverride None¡±ÐÞ¸ÄΪ¡°AllowOverride All¡±¡£Ð޸ĺóµÄÉèÖÃÈçÏ£º

<directory>
    AllowOverride All
    ...
</directory>

µÇ¼ºó¸´ÖÆ

1.4¡¢ÖØÆôApacheЧÀÍÆ÷

ÐÞ¸ÄÍêApacheÉèÖÃÎļþÖ®ºó £¬ÐèÒªÖØÆôApacheЧÀÍÆ÷ £¬ÒÔʹеÄÉèÖÃÉúЧ¡£ÏêϸÏÂÁîÈçÏ£º

sudo service httpd restart

µÇ¼ºó¸´ÖÆ

2¡¢Í¨¹ýÐÞ¸ÄLaravelÉèÖÃÎļþ¾ÙÐÐÉèÖÃ

ÈôÊÇÄú¶ÔApacheµÄÏà¹ØÉèÖò»Ïàʶ £¬»òÕßÎÞ·¨Ö±½ÓÐÞ¸ÄЧÀÍÆ÷ÉèÖÃÎļþ £¬Ôò¿ÉÒÔͨ¹ýÐÞ¸ÄLaravelÉèÖÃÎļþÍù¸´µôindex.php¡£ÏÂÃæÊÇÏêϸµÄÉèÖð취£º

2.1¡¢·­¿ªLaravelÉèÖÃÎļþ

Ê×ÏÈ £¬ÕÒµ½´æ·ÅLaravel5ÏîÄ¿µÄ¸ùĿ¼ £¬È»ºó½øÈëµ½¡°config¡±Ä¿Â¼Ï £¬ÕÒµ½ÃûΪ¡°app.php¡±µÄÉèÖÃÎļþ¡£

2.2¡¢ÐÞ¸ÄÉèÖÃÎļþ

ÔÚ¡°app.php¡±ÎļþÖÐ £¬ÕÒµ½ÒÔÏÂÁ½ÐдúÂ룺

'index' =&gt; 'index.php',
...
'url' =&gt; 'http://localhost',

µÇ¼ºó¸´ÖÆ

½«¡°index.php¡±ÐÞ¸ÄΪ¿Õ×Ö·û´® £¬Ð޸ĺóµÄ´úÂëÈçÏ£º

'index' =&gt; '',
...
'url' =&gt; 'http://localhost',

µÇ¼ºó¸´ÖÆ

ÕâÑù £¬»á¼ûLaravel5ÏîĿʱ¾Í¿ÉÒÔÖ±½ÓÈ¥µôindex.phpÁË¡£

ÐèҪעÖصÄÊÇ £¬ÈôÊÇÄúµÄLaravelÏîÄ¿°²ÅÅÔÚ×ÓĿ¼Ï £¬ÔòÐèÒª½«¡°url¡±Ñ¡ÏîÐÞ¸ÄΪ¡°http://localhost/your_sub_folder¡± £¬ÆäÖС°your_sub_folder¡±ÎªÄúµÄ×ÓĿ¼Ãû³Æ¡£

×ܽ᣺

±¾ÎÄÏÈÈÝÁËÁ½ÖÖÒªÁì £¬¿ÉÒÔÈ¥µôLaravel5ÖеÄindex.php¡£µÚÒ»ÖÖÒªÁìÐèÒªÔÚApacheÉèÖÃÎļþÖоÙÐÐÐÞ¸Ä £¬ÊʺÏÓÚÓÐЧÀÍÆ÷ÖÎÀíÂÄÀúµÄÓû§ £»µÚ¶þÖÖ·½¹æÔòÔ½·¢¼òÆÓ £¬Í¨¹ýÐÞ¸ÄLaravelÉèÖÃÎļþ¼´¿ÉʵÏÖ¡£ÎÞÂÛÄúÑ¡ÔñÄÄÖÖÒªÁì £¬¶¼¿ÉÒÔÈÃÄúµÄLaravel5ÏîÄ¿Ô½·¢ÓѺà £¬Ìá¸ßÓû§ÌåÑéºÍSEOЧ¹û¡£

ÒÔÉϾÍÊÇlaravel5Ôõôȥµôindex.phpµÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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