»ª·áÈí¼þ

»¥ÁªÍøÈí¼þ×ÊÔ´¹²Ïí

µ±Ç°Î»ÖãºÊ×Ò³ -> ×ÛºÏƵµÀ -> Õ¾³¤Ö®¼Ò

IIS8ÈçºÎ°²×°ºÍʹÓÃURLÖØд¹¤¾ß-URL Rewrite

±¾ÎļǼÁËÔÚIIS8Ï°²×°ºÍʹÓÃURL Rewrite²å¼þµÄ²½Ö裬Ïêϸ¾ÙÀý˵Ã÷ÈçºÎʹÓÃURLÖØд¹¤¾ßʵÏÖ301Öض¨ÏòµÄ¹¦ÄÜ¡£

ÏÂÔغͰ²×°URL Rewrite

IIS8ĬÈÏÊÇûÓа²×°URLÖØд¹¤¾ßµÄ£¬±ØÐëÒª×Ô¼ºÏÂÔØ°²×°¡£

Èç¹ûIISÉÏĬÈÏÓа²×°Webƽ̨°²×°³ÌÐò£¬ÎÒÃÇ¿ÉÒÔʹÓÃƽ̨×Ô¶¯°²×°URL RewriteÖØд¹¤¾ß£¬´ò¿ªIIS(Internet ÐÅÏ¢·þÎñ¹ÜÀíÆ÷)£¬ÔÚ¹ÜÀíÆ÷Ö÷Ò³ÖÐÕÒµ½¹ÜÀíÏ´ò¿ªWebƽ̨°²×°³ÌÐò£¬ÈçÏÂͼ£º

´ò¿ªWebƽ̨°²×°³ÌÐò×Ô¶¯°²×°URL Rewrite

ÔÚWebƽ̨°²×°³ÌÐòÖÐÑ¡Ôñ²úÆ·¡··þÎñÆ÷£¬ÔÚÁбíÖÐÕÒµ½URLÖØд¹¤¾ß£¬µã»÷Ìí¼Óºóµã»÷°²×°£¬¼´¿É×Ô¶¯°²×°ºÃ£¡ÈçÏÂͼ£º

°²×°URLÖØд¹¤¾ß²å¼þ

ÎÒÃÇÒ²¿ÉÒÔÊÖ¶¯ÏÂÔØURL Rewrite²å¼þ£¬ÕâÊǹٷ½µØÖ·£ºURL RewriteÏÂÔØ

ÕâÀïÓÐÁ½ÖÖ·½Ê½£¬Ò»ÖÖÊÇÏÂÔØWebƽ̨°²×°³ÌÐòµÄ²å¼þ°ü½øÐÐÔÚÏß°²×°£¬µã»÷ÏÂÔØÒ³ÃæÖеÄInstall this extension°´Å¥ÏÂÔØurlrewrite2.exe°²×°³ÌÐò£¬Ë«»÷ºó»á×Ô¶¯ÔËÐÐWebƽ̨°²×°³ÌÐò°²×°URLÖØд¹¤¾ß2.0¡£

°²×°²å¼þ

ʹÓÃWebƽ̨°²×°³ÌÐò°²×°URLÖØд¹¤¾ß

ÁíÍâÒ»ÖÖ·½Ê½ÊÇÏÂÔØÀëÏß°²×°°ü£¬ÏÂÔصØÖ·ÔÚÒ³Ãæ¿¿½üµ×²¿µÄDownload URL Rewrite Module 2.0Çø¿é¡£²»¹ýҪѡÔñ¶ÔÓ¦×Ô¼ºÍøÕ¾·þÎñÆ÷µÄ°æ±¾£¬±ÈÈç±ÊÕߵķþÎñÆ÷ÊÇ64룬ÖÐÎļòÌ壬¾ÍҪѡÔñÈçͼËùʾµÄ°æ±¾£º

Ñ¡ÔñURLÖØд¹¤¾ß°æ±¾

ÕâÁ½ÖÖ·½Ê½¶¼Ã»ÓÐʲô¸´ÔӵIJ½Ö裬»ù±¾Ò»Ö±µã»÷ÏÂÒ»²½Ö±µ½Íê³É¾Í¿ÉÒÔÁË¡£


2015/10/21¸üУ¬ÏÖÔÚÏÂÔØÁ´½ÓÖ»Óа汾µÄÇø±ð£¬Ã»ÓÐÓïÑÔÇø±ðÁË£¬ÓïÑÔ»á¸ù¾Ý·þÎñÆ÷×Ô¶¯Åжϣº

Ñ¡ÔñURLÖØд¹¤¾ß²å¼þµÄϵͳ°æ±¾


ÔÚIISÉÏʹÓÃURLÖØд¹¤¾ßµÄ¾ßÌå²½Öè

URL RewriteÖØд¹¤¾ßÖ÷ÒªÊÇʹÓÃÕýÔò»òÕßͨÅä·û½øÐÐÆ¥Å䣬¶ÔÓÚÕýÔòºÍͨÅä·ûÒªÓÐÒ»¶¨µÄÁ˽⣬¿ÉÒÔÍøÉϲéÏÂÏà¹ØµÄ×ÊÁÏ£¬ÕâÀィÒé¿´¹Ù·½µÄ°ïÖúÎĵµ£ºURL Rewrite Module Configuration ºÍ IIS URL ÖØдģ¿é

Ê×ÏÈ´ò¿ªIISÏÂÍøÕ¾µÄURLÖØд¹¦ÄÜ£º

urlÖØдͼ±ê


ÎÒÃÇÓÒ¼ü»òÕßÓұߵIJÙ×÷²Ëµ¥À¸ÖÐÑ¡ÔñÌí¼Ó¹æÔò£¬ÎÒÃÇ¿ÉÒÔ¿´µ½Ä¬ÈÏÓÐÌṩºÜ¶à¹æÔòÄ£°å£¬ÕâÀïÎÒÃÇÑ¡ÔñÒ»¸ö¿Õ°×¹æÔò×÷ΪÌí¼Ó301Öض¨ÏòµÄÖØдÑÝʾ£º

ÖØдµÄÑ¡Ôñ¹æÔòÄ£°å


´ò¿ª±à¼­ÈëÕ¾¹æÔòµÄ½çÃæºó£¬ÎÒÃÇÊäÈë×Ô¼º¶¨ÒåµÄÃû³Æ£¬Ñ¡ÔñÆ¥ÅäURLµÄ·½Ê½ºÍʹÓõĹæÔò£¬¹æÔò¿ÉÒÔÑ¡ÔñÕýÔò±í´ïʽ¡¢Í¨Åä·ûºÍÍêÈ«Æ¥Å䣬ÕâÀïʹÓõÄÊÇÕýÔò×÷ΪʾÀý¡£×îºóÔÚÆ¥ÅäURLģʽÊäÈë.*£¨ÕýÔò±í´ïʽ£¬±íʾƥÅäËùÓеÄ·¾¶£¬ÕâÀï¾ÍÊÇÎĵµÖеÄrule patterns£©¡£

ÉèÖÃrule patterns

¹ØÓÚÕâÀïµÄ¹æÔòģʽ£¬ÕâÀィÒé¿´ÕâƪÎÄÕ£ºÏê½âIISÖÐURLÖØд¹¤¾ßµÄÆ¥ÅäURL-¹æÔòģʽ(rule patterns)


½ÓÏÂÀ´Ìí¼ÓURL¹ýÂËÌõ¼þ£¬Âß¼­·Ö×éÄǸù¾Ý×Ô¼ºµÄÐèÇóÑ¡Ôñ£¬±ÈÈç±ÊÕßÊÇ´òËã×öÈ«Õ¾301Ìøת£¬ËùÒÔÕâÀïÓÃÈÎÒâÆ¥Åä¡£µã»÷Ìí¼Ó°´Å¥£¬ÉèÖÃÊäÈëΪ{HTTP_HOST} £¬ÀàÐÍΪÓëģʽƥÅ䣬ģʽΪ^www.shiyousan.com$£¬ ÓÉÓÚ֮ǰѡÔñÁËʹÓÃÕýÔò×÷ΪƥÅä¹æÔò£¬ËùÒÔÕâÀïҪעÒâʹÓÃÕýÈ·Æ¥Åä¹æÔò¡£ÕâÀïÖ÷ÒªÊÇÉèÖÃÆ¥ÅäËùÓдøwwwµÄ¶þ¼¶ÓòÃû·¾¶£¬ÎÞÂÛÊÇ·ñÓдø²ÎÊý»òÕßĿ¼ȫ²¿¶¼»áÆ¥Åäµ½£¬µÈÓÚ¶þ¼¶ÓòÃûȫվƥÅä½øÐÐÖض¨ÏòÌøת¡£

PS:

  1. ·þÎñÆ÷±äÁ¿Èç¹ûûÓоͷſղ»ÉèÖá£

  2. {HTTP_HOST}·þÎñÆ÷±äÁ¿ÀàÐÍ£¬±íʾËùÇëÇóµÄÖ÷»ú£¬ÊǹæÔòÌõ¼þÊäÈëµÄÖµ¡£Èç¹ûÑ¡ÔñµÄÀàÐÍΪÓëģʽƥÅ䣬һ°ã³£ÓÃÓÐQUERY_STRING¡¢HTTP_HOST¡¢SERVER_PORT¡¢SERVER_PORT_SECURE¡¢REQUEST_URIµÈ·þÎñ±äÁ¿£¬½¨Òé¿´ÕâƪÎÄÕ£ºÏê½âIISÖÐURLÖØд¹¤¾ßµÄ¹æÔòÌõ¼þ(Rule conditions)£¬ÀïÃæÓиü¼ÓÏêϸµÄ˵Ã÷¡£

ÉèÖÃcondition patterns


×îºóÒ»²½¾ÍÊÇÉèÖòÙ×÷£¬²Ù×÷ÀàÐÍÓÐÎå¸öÑ¡ÏÖØд¡¢ÎÞ¡¢Öض¨Ïò¡¢×Ô¶¨ÒåÏìÓ¦¡¢ÖÐÖ¹ÇëÇó¡£±ÊÕßÑ¡ÔñµÄÊÇÖض¨Ïò£¬È»ºóÉèÖÃÖض¨ÏòURL£¬ÕâÀïµÄURLÊÇ£ºhttp://shiyousan.com/{R:0} ¡£±íʾËùÓÐwww.shiyousan.comµÄURLµØÖ·(°üÀ¨Óдø²ÎÊýµÄµØÖ·ÒÔ¼°¶à¼¶Ä¿Â¼µÄµØÖ·)¶¼ÒªÌøתµ½shiyousan.comÕâ¸ö¶¥¼¶ÓòÃûµÄURLÖС£×îºóÖض¨ÏòÀàÐÍÑ¡ÔñÓÀ¾Ã301¾Í´ó¹¦¸æ³ÉÁË£¡£¡£¡

PS:{R:0}ÊÇ·´ÏòÒýÓ㬱íʾÓëÆ¥Åäurlģʽ.*µÄÕýÔòÈ«²¿Æ¥Å䣬Ҳ¾ÍÊÇrule patternsµÄÆ¥Åä¹æÔò£¬¾ßÌå¿ÉÒÔ¿´ÕâƪÎÄÕ£ºÏê½âIISÖеÄURLÖØд¹¤¾ßϹØÓÚ²Ù×÷Öض¨ÏòURLÖеÄ{R:N}Óë{C:N}£¬Ò²¿ÉÒÔ¿´¹Ù·½µÄÎĵµ£ºUsing back-references in rewrite rules

R:0Óërule patterns



ÉÏһƪ£ºwindows 2012 iis8 °²×°²½Öè
ÏÂһƪ£ºiis8.0 httpsÅäÖý̳Ì

ÆÀÂÛ

ÕÊ¡¡¡¡ºÅ: ÃÜÂë: (ÐÂÓû§×¢²á)
Ñé Ö¤ Âë:
±í¡¡Çé:
ÄÚ¡¡¡¡ÈÝ:

ËÑË÷
×îÐÂÎÄÕÂ
ͼƬÖ÷Ìâ
ÈÈÃÅÎÄÕÂ
ÍƼöÎÄÕÂ
Ïà¹ØÎÄÕÂ

    Ê× Ò³   |   °æȨÉùÃ÷   |   ¹ØÓÚÎÒÃÇ   |   ¹ã¸æ·þÎñ   |   ÁªÏµÎÒÃÇ   |   ÊÖ»ú°æ    |   ÍøÕ¾µØͼ
    Copyright@zhuchunyu.com all rights reserved
    Powered by zhuchunyu.com 2018-2025 zhuchunyu.com ÍîICP±¸05011767ºÅ-23