尊龙凯时人生就是搏

ÔõÑùʹÓÃNginx¾ÙÐÐÇëÇóÖض¨ÏòºÍURLÖØд

ÔõÑùʹÓÃnginx¾ÙÐÐÇëÇóÖض¨ÏòºÍurlÖØд

Nginx×÷Ϊһ¿î¸ßÐÔÄܵÄWebЧÀÍÆ÷ºÍ·´ÏòÊðÀíЧÀÍÆ÷£¬³ýÁËÌṩ»ù±¾µÄÇëÇó´¦ÀíÍ⣬»¹¿ÉÒÔʹÓÃÆäÇ¿Ê¢µÄÖض¨ÏòºÍURLÖØд¹¦Ð§¶ÔÇëÇó¾ÙÐнøÒ»²½´¦Àí¡£±¾ÎĽ«ÏÈÈÝÔõÑùʹÓÃnginx¾ÙÐÐÇëÇóÖض¨ÏòºÍurlÖØд£¬²¢¸½ÉÏ´úÂëʾÀý¡£

ÇëÇóÖض¨Ïò

ÇëÇóÖض¨ÏòÊÇÖ¸ÔÚÎüÊÕµ½¿Í»§¶ËÇëÇóºó£¬½«ÇëÇóÖض¨Ïòµ½ÁíÒ»¸öURL¡£NginxÌṩÁËÁ½ÖÖ·½·¨ÊµÏÖÇëÇóÖض¨Ïò£ºÊ¹ÓÃreturnÖ¸ÁîºÍʹÓÃrewriteÖ¸Áî¡£

ʹÓÃreturnÖ¸Áî¾ÙÐÐÇëÇóÖض¨Ïò£¬Ê¾ÀýÈçÏ£º

server {
    listen 80;
    server_name oldsite.com;
    return 301 http://newsite.com$request_uri;
}

µÇ¼ºó¸´ÖÆ

ÉÏÊöÉèÖý«ËùÓÐÇëÇóת·¢µ½http://newsite.com£¬²¢±£´æԭʼURL¡£

ʹÓÃrewriteÖ¸Áî¾ÙÐÐÇëÇóÖض¨Ïò£¬Ê¾ÀýÈçÏ£º

server {
    listen 80;
    server_name oldsite.com;
    rewrite ^(.*)$ http://newsite.com$1 permanent;
}

µÇ¼ºó¸´ÖÆ

ÉÏÊöÉèÖý«ËùÓÐÇëÇóת·¢µ½http://newsite.com£¬²¢±£´æԭʼURL¡£Ê¹ÓÃpermanentÒªº¦×ÖÌåÏÖÖض¨ÏòÊÇÓÀÊÀÐԵģ¬ÈôÊÇҪʹÓÃÔÝʱÖض¨Ïò£¬¿ÉÒÔʹÓÃredirectÒªº¦×Ö¡£

URLÖØд

URLÖØдÊÇָͨ¹ýÐÞ¸ÄURLµÄ·½·¨£¬¶ÔÇëÇó¾ÙÐд¦Àí¡£NginxʹÓÃrewriteÖ¸ÁîÀ´ÊµÏÖURLÖØд¡£

ÒÔÏÂÊÇÒ»¸ö¼òÆÓµÄURLÖØдʾÀý£¬½«ËùÓÐÒÔ/user¿ªÍ·µÄURLÖØдΪ/user/profile£º

location / {
    rewrite ^/user(.*)$ /user/profile$1 last;
}

µÇ¼ºó¸´ÖÆ

ÉÏÊöÉèÖý«/user¿ªÍ·µÄURLÖØдΪ/user/profile£¬²¢½«ÖØдºóµÄURLת´ï¸øºóÐø´¦Àí¡£

³ýÁ˼òÆÓµÄURLÖØдÍ⣬Nginx»¹Ö§³ÖʹÓÃÕýÔò±í´ïʽ¾ÙÐиüÎÞаµÄURLÖØд¡£ÒÔÏÂÊÇÒ»¸öʹÓÃÕýÔò±í´ïʽµÄURLÖØдʾÀý£¬½«/user/123ÖØдΪ/user/profile?id=123£º

location / {
    rewrite ^/user/(d+)$ /user/profile?id=$1 last;
}

µÇ¼ºó¸´ÖÆ

ÉÏÊöÉèÖÃÖУ¬(d+)ÌåÏÖÆ¥ÅäÒ»¸ö»ò¶à¸öÊý×Ö£¬²¢½«Æä×÷Ϊ²ÎÊýת´ï¸ø/user/profile¡£

ÐèҪעÖصÄÊÇ£¬URLÖØд¿ÉÄܻᵼÖÂÖض¨ÏòÑ­»·£¬Òò´ËÐèÒªÉóÉ÷ÉèÖá £¿ÉÒÔʹÓÃif»òÕßreturnÖ¸ÁîÍŽáÌõ¼þÓï¾äÀ´×èÖ¹Öض¨ÏòÑ­»·µÄ±¬·¢¡£

×ÛÉÏËùÊö£¬Ê¹ÓÃNginx¾ÙÐÐÇëÇóÖض¨ÏòºÍURLÖØд¿ÉÒÔÓÃÓÚʵÏÖһЩ³£¼ûµÄÐèÇó£¬Èç¾ÉÍøÖ·Ìøת¡¢Ò³ÃæÌøת¡¢URL²ÎÊý´¦ÀíµÈ¡£Í¨¹ýºÏÀíµÄÉèÖ㬿ÉÒÔÌáÉýÍøÕ¾µÄ¿ÉÓÃÐÔºÍÓû§ÌåÑé¡£

Ï£Íû±¾ÎĶÔÄãÃ÷È·ºÍÓ¦ÓÃNginx¾ÙÐÐÇëÇóÖض¨ÏòºÍURLÖØдÓÐËù×ÊÖú¡£ÈôÊÇÄãÐèÒª¸üÏêϸµÄÉèÖúÍʾÀý£¬Çë²Î¿¼NginxµÄ¹Ù·½Îĵµ»òÕßÏà¹ØµÄÊÖÒÕÎÄÕ¡£

ÒÔÉϾÍÊÇÔõÑùʹÓÃNginx¾ÙÐÐÇëÇóÖض¨ÏòºÍURLÖØдµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是搏

18523999891

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

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

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