thinkphp iisα¾²Ì¬²»Æð×÷ÓÃ
½üÄêÀ´£¬Ô½À´Ô½¶àµÄ¿ª·¢ÕßÑ¡ÔñʹÓÃthinkphp¿ò¼ÜÀ´¹¹½¨×Ô¼ºµÄwebÓ¦Ó᣶øÔÚʹÓÃthinkphp¿ò¼ÜÖУ¬Î±¾²Ì¬ÊÇÒ»¸ö³£¼ûµÄÎÊÌâ¡£ÓÈÆäÊÇÔÚiisЧÀÍÆ÷ÉÏʹÓÃthinkphp¿ò¼Üʱ£¬Ðí¶à¿ª·¢Õß±¨¸æ˵α¾²Ì¬²»Æð×÷Óá£ÄÇô£¬¸ÃÔõÑù½â¾öthinkphp iisα¾²Ì¬²»Æð×÷ÓõÄÎÊÌâÄØ£¿±¾ÎĽ«¶Ô´Ë¾ÙÐÐÆÊÎöÏ¢Õù´ð¡£
Ò»¡¢Ê²Ã´ÊÇα¾²Ì¬
Ê×ÏÈ£¬ÎÒÃÇÐèÒªÏàʶʲôÊÇα¾²Ì¬¡£Í¨³£À´Ëµ£¬ÍøÕ¾µÄURLÁ´½ÓÊÇ´øÓвÎÊýµÄ£¬ÀýÈ磺www.example.com/index.php?id=123¡£ÕâÖַǾ²Ì¬µÄURLÁ´½Ó²»µ«²»ÑŹۣ¬²¢ÇÒÒ²µ¹ÔËÓÚËÑË÷ÒýÇæµÄÅÀÈ¡ºÍÓû§µÄÌåÑé¡£ÓÚÊÇ£¬Î±¾²Ì¬·ºÆðÁË£¬Ëü½«Á´½Óת»»Îª¸ü¼ò½éºÍÓïÒ廯µÄÐÎʽ£¬ºÃ±È£ºwww.example.com/id/123.html¡£ÕâÑùµÄURL¿´ÆðÀ´Ô½·¢ÑŹۡ¢Ò×ÓÚÃ÷È·£¬Ò²¸üÀûÓÚËÑË÷ÒýÇæµÄÓÅ»¯¡£
¶þ¡¢ThinkPHP¿ò¼ÜÖеÄα¾²Ì¬
ÔÚThinkPHP¿ò¼ÜÖУ¬Î±¾²Ì¬ÊÇͨ¹ýURLÖØд¹¦Ð§ÊµÏֵġ£Ò»Ñùƽ³£ÇéÐÎÏ£¬ÎÒÃÇʹÓÃ.htaccessÎļþÀ´ÊµÏÖApacheЧÀÍÆ÷µÄURLÖØд¹¦Ð§¡£¶øÔÚIISЧÀÍÆ÷ÉÏ£¬ÎÒÃÇʹÓÃweb.configÎļþÀ´ÊµÏÖURLÖØд¡£
Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»
ÏÂÃæÊÇÒ»¸ö¼òÆÓµÄweb.configʾÀý£¬¿ÉÒÔʵÏÖÒ»¸ö»ù±¾µÄα¾²Ì¬¹æÔò:
<configuration> <system.webServer> <rewrite> <rules> <rule name="Rewrite to index.php"> <match url="^(.*)$" /> <conditions logicalGrouping="MatchAny"> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> </conditions> <action type="Rewrite" url="index.php/{R:1}" /> </rule> </rules> </rewrite> </system.webServer> </configuration>
µÇ¼ºó¸´ÖÆ
ÒÔÉÏ´úÂë»á½«ËùÓÐÇëÇó¶¼ÖØдµ½index.phpÎļþ£¬²¢½«URLµÄ²ÎÊý²¿·Öͨ¹ýб¸ÜÍÑÀëÌí¼Óµ½URLµÄβ²¿¡£ÕâÑù£¬ÎÒÃǾͿÉÒÔʹÓÃÀàËÆwww.example.com/index.php/id/123µÄÁ´½Ó·½·¨À´»á¼ûÒ³Ãæ¡£
Èý¡¢ThinkPHP¿ò¼ÜÖеÄα¾²Ì¬²»Æð×÷ÓÃÎÊÌâÆÊÎö
ÔÚʹÓÃThinkPHP¿ò¼Üʱ£¬ÓÐЩ¿ª·¢Õß·´Ó¦ÎÞ·¨ÀÖ³ÉʵÏÖα¾²Ì¬¹¦Ð§¡£ÎÊÌâ·ºÆðÔÚIISЧÀÍÆ÷ÉÏʱ£¬¾ÍÔ½·¢³£¼û¡£Õâ¸öÎÊÌâµÄ·ºÆðͨ³£ÊÇÓÉÒÔϼ¸¸öÔµ¹ÊÔÓɵ¼Öµģº
ЧÀÍÆ÷δÆôÓÃrewriteÄ£¿é¡£
ÔÚIISЧÀÍÆ÷ÉÏÆôÓÃrewriteÄ£¿éºÜÊÇÖ÷Òª¡£ÈôÊÇЧÀÍÆ÷δÆôÓÃrewriteÄ£¿é£¬web.configÎļþÖеĹæÔò½«²»»á±»Ó¦Óá£Òò´Ë£¬ÔÚ¼ì²éÆäËûÎÊÌâ֮ǰ£¬Ó¦¸ÃÈ·±£rewriteÄ£¿éÒÑÆôÓá£
ȱÉÙweb.configÎļþ¡£
ʵÏÖα¾²Ì¬ÐèÒª½«web.configÎļþ°²ÅÅÔÚÓ¦ÓõĸùĿ¼ÖС£ÈôÊÇweb.configÎļþȱʧ¡¢Ãû³Æ»òλÖò»×¼È·£¬Ôòα¾²Ì¬¹æÔò½«²»»á±»Ó¦Óá£
α¾²Ì¬¹æÔòÓÐÎó¡£
α¾²Ì¬¹æÔòÔÚweb.configÎļþÖоÙÐÐÉèÖã¬ÈôÊÇ·ºÆð¹ýʧ£¬¿ÉÄܻᵼÖ¹æÔòÎÞ·¨Õý³£Ó¦Óá£ÔÚÈ·ÈÏrewriteÄ£¿éÒÑÆôÓò¢ÇÒweb.configÎļþ±£´æµÄÇéÐÎÏ£¬ÐèÒª×Ðϸ¼ì²éα¾²Ì¬¹æÔòÊÇ·ñ׼ȷ¡£
ËÄ¡¢½â¾öThinkPHP¿ò¼ÜÖÐα¾²Ì¬²»Æð×÷ÓõÄÎÊÌâ
Õë¶ÔÉÏÊöÎÊÌ⣬ÎÒÃÇÏÈÈÝÒÔϼ¸ÖÖ½â¾öÒªÁ죺
ÆôÓÃrewriteÄ£¿é£º
ÔÚIISЧÀÍÆ÷ÉÏÆôÓÃrewriteÄ£¿éµÄÒªÁìÈçÏ£º
1£©ÒÔÖÎÀíÔ±Éí·Ý·¿ªIISÖÎÀíÆ÷¡£
2£©ÔÚ×ó²àÃæ°åÖÐÕÒµ½Ð§ÀÍÆ÷£¬ÓÒ»÷¡°ÖÎÀíЧÀÍÆ÷¡±£¬Ñ¡Ôñ¡°Ìí¼Ó½ÇÉ«ºÍ¹¦Ð§¡±¡£
3£©ÕÒµ½ºÍÑ¡Ôñ¡°Web Server (IIS)¡±½ÇÉ«£¬µã»÷¡°ÏÂÒ»²½¡±¡£
4£©ÕÒµ½ºÍÑ¡Ôñ¡°Web Server (IIS)¡±½ÇɫЧÀÍ£¬²¢ÔÚÓҲ๴ѡ¡°URLÖØд¡±£¬µã»÷¡°ÏÂÒ»²½¡±¡£
5£©µã»÷¡°×°Öá±Íê³É×°Öã¬ÖØÆôIISЧÀÍ¡£
È·ÈÏweb.configÎļþ±£´æÇÒ׼ȷ£º
È·ÈÏÎļþÊÇ·ñ±£´æ¼°ÊÇ·ñ׼ȷ¡£ÈôÊÇÎļþÒѱ£´æ£¬ÇëÈ·±£Ãû³ÆÊÇ·ñ׼ȷ£¬Î»ÖÃÊÇ·ñ׼ȷ¡£
¼ì²éα¾²Ì¬¹æÔòÊÇ·ñ׼ȷ£º
α¾²Ì¬¹æÔò±ØÐè׼ȷÉèÖ㬲»È»ÎÞ·¨Õý³£ÔËÐС£Òò´Ë£¬ÔÚ¼ì²éα¾²Ì¬¹æÔò֮ǰ£¬ÄúÐèÒª×Ðϸ¼ì²éËüÃÇÊÇ·ñ׼ȷ±àд¡£ÔÚweb.configÎļþÖеĹæÔò±£´æÓï·¨¹ýʧ½«µ¼ÖÂα¾²Ì¬²»Æð×÷Ó᣿ÉÒÔͨ¹ý´ÓÈÕÖ¾ÖÐÕÒµ½¹ýʧÐÂÎÅÀ´ÅÅÅÌÎÊÌâ¡£×î³£¼ûµÄ¹ýʧ°üÀ¨¹æÔòÓï·¨¹ýʧ£¬È±ÉÙÌõ¼þ»òÐж¯ÔªËصȡ£
µ÷½âÓ¦ÓóÌÐòÂß¼£º
µ±ËùÓеÄЧÀÍÆ÷ÉèÖúÍÉèÖö¼ÒÑ׼ȷÍê³É£¬µ«Î±¾²Ì¬¹¦Ð§ÈÔÈ»ÎÞ·¨Õý³£ÊÂÇéʱ£¬¿ÉÄÜÐèÒªÖØмì²éÓ¦ÓóÌÐòµÄÂß¼¡£ÀýÈ磬¼ì²éThinkPHP¿ò¼ÜµÄ·ÓɹæÔòºÍURLÌìÉúÒªÁìÊÇ·ñ׼ȷ¡£ÓÐʱ£¬Ó¦ÓóÌÐòµÄÂß¼¿ÉÄܻᵼÖÂα¾²Ì¬ÎÞ·¨Õý³£ÊÂÇé¡£
Îå¡¢×ܽá
ͨ¹ýÒÔÉÏÄÚÈÝ£¬ÎÒÃÇÏàʶµ½ThinkPHP¿ò¼ÜÖÐα¾²Ì¬²»Æð×÷ÓõÄÎÊÌâͨ³£ÊÇÓÉrewriteÄ£¿éδÆôÓá¢web.configÎļþ¹ýʧ¡¢Î±¾²Ì¬¹æÔò¹ýʧµÈ¶àÖÖÔµ¹ÊÔÓɵ¼Öµġ£Í¨¹ýÆôÓÃrewriteÄ£¿é¡¢È·ÈÏweb.configÎļþºÍα¾²Ì¬¹æÔò£¬ÒÔ¼°¼ì²éÓ¦ÓóÌÐòµÄÂß¼£¬ÎÒÃÇ¿ÉÒÔ½â¾öThinkPHP¿ò¼ÜÖÐα¾²Ì¬²»Æð×÷ÓõÄÎÊÌ⡣ֻҪȷ¾Ù¼öÐÐ׼ȷµÄЧÀÍÆ÷ÉèÖúÍÓ¦ÓóÌÐòÉè¼Æ£¬Õâ¸öÎÊÌâ²»ÄÑÃ÷¾ö¡£
ÒÔÉϾÍÊÇthinkphp iisα¾²Ì¬²»Æð×÷ÓõÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡