×ðÁú¿­Ê±

NginxÖض¨ÏòÉèÖÃʵս £¬ÊµÏÖÍøÕ¾Á÷Á¿×ªÒÆ

nginxÖض¨ÏòÉèÖÃʵս £¬ÊµÏÖÍøÕ¾Á÷Á¿×ªÒÆ

½üÄêÀ´ £¬Ëæ×Å»¥ÁªÍøµÄѸÃÍÉú³¤ £¬ÍøÕ¾Á÷Á¿×ªÒƱäµÃÔ½À´Ô½³£¼û¡£µ±ÎÒÃÇÐèÒª½«Ò»¸öÍøÕ¾µÄÁ÷Á¿Öض¨Ïòµ½ÁíÒ»¸öÍøվʱ £¬NginxµÄÖض¨ÏòÉèÖÃÄܹ»ºÜºÃµØÖª×ã×ðÁú¿­Ê±ÐèÇó¡£±¾ÎĽ«´Óʵս½Ç¶È³ö·¢ £¬ÏÈÈÝÔõÑùʹÓÃNginxµÄÖض¨ÏòÉèÖÃʵÏÖÍøÕ¾Á÷Á¿×ªÒƵÄÒªÁì £¬²¢Ìṩ´úÂëʾÀý¡£

µ±ÎÒÃÇÐèÒª½«Ò»¸ö¾ÉÍøÕ¾µÄÁ÷Á¿×ªÒƵ½Ò»¸öÐÂÍøվʱ £¬¿ÉÒÔͨ¹ýNginxµÄÖض¨ÏòÉèÖÃÀ´ÊµÏÖÕâһĿµÄ¡£ÏÂÃæÊÇÒ»¸ö»ù±¾µÄNginxÖض¨ÏòÉèÖÃʾÀý £¬ÔÚÉèÖÃÎļþÖÐÌí¼ÓÒÔÏÂÄÚÈÝ£º

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

µÇ¼ºó¸´ÖÆ

ÒÔÉÏÉèÖý«»á½«ËùÓÐÀ´×Ôoldsite.comµÄÁ÷Á¿Öض¨Ïòµ½newsite.com¡£ÆäÖÐ £¬return 301ÌåÏÖÖ´ÐÐ301Öض¨Ïò £¬http://newsite.com$request_uriÌåÏÖÖض¨Ïòµ½http://newsite.com²¢±£´æԭʼÇëÇóµÄURI¡£

³ýÁË»ù±¾µÄÖض¨ÏòÉèÖà £¬Nginx»¹ÌṩÁ˸ü¶à¸ß¼¶µÄÖض¨ÏòÉèÖÃÑ¡Ïî¡£ÀýÈç £¬ÎÒÃÇ¿ÉÒÔʹÓÃÕýÔò±í´ïʽÀ´ÊµÏÖ¸üÖØ´óµÄÖض¨Ïò¹æÔò¡£ÏÂÃæÊÇÒ»¸öʹÓÃÕýÔò±í´ïʽµÄÖض¨ÏòÉèÖÃʾÀý£º

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

µÇ¼ºó¸´ÖÆ

ÒÔÉÏÉèÖý«»áδÀ´×Ôoldsite.comµÄËùÓÐÁ÷Á¿Öض¨Ïòµ½newsite.com £¬²¢±£´æԭʼÇëÇóµÄURI¡£

³ýÁËÕë¶ÔÕû¸öÍøÕ¾µÄÁ÷Á¿Öض¨Ïò £¬ÎÒÃÇ»¹¿ÉÒÔÕë¶ÔÌض¨µÄURL¾ÙÐÐÖض¨Ïò¡£ÀýÈç £¬ÎÒÃÇ¿ÉÒÔ½«oldsite.com/aboutÒ³ÃæµÄÁ÷Á¿Öض¨Ïòµ½newsite.com/aboutÒ³Ãæ¡£ÏÂÃæÊÇÒ»¸öÕë¶ÔÌض¨URLµÄÖض¨ÏòÉèÖÃʾÀý£º

location /about {
  rewrite ^ http://newsite.com/about permanent;
}

µÇ¼ºó¸´ÖÆ

ÒÔÉÏÉèÖý«»áδÀ´×Ôoldsite.com/aboutÒ³ÃæµÄÁ÷Á¿Öض¨Ïòµ½newsite.com/aboutÒ³Ãæ¡£

³ýÁËÉÏÊöµÄ»ù±¾Ó÷¨ £¬Nginx»¹ÌṩÁ˸ü¶à¸ß¼¶µÄÖض¨ÏòÉèÖÃÑ¡Ïî £¬ÀýÈçÖض¨Ïòµ½Ö¸¶¨URLµÄÖ¸¶¨Î»ÖᢴøÓÐÕýÔò±í´ïʽµÄ¸ß¼¶Æ¥ÅäµÈ¡£ÕâЩѡÏî¿ÉÒÔÈÃÎÒÃÇÔ½·¢ÎÞаµØÉèÖÃÁ÷Á¿Öض¨Ïò¹æÔò¡£

ÐèҪעÖصÄÊÇ £¬µ±ÎÒÃÇÉèÖÃÁËÖض¨Ïò¹æÔòʱ £¬Ó¦µ±ÉóÉ÷µØ²âÊÔºÍÑéÖ¤ÕâЩ¹æÔòÊÇ·ñƾ֤ԤÆÚÊÂÇé¡£ÔÚÉèÖÃÎļþÖÐÌí¼ÓÒ»ÌõÖض¨Ïò¹æÔòʱ £¬Ó¦µ±ÖØмÓÔØNginxÉèÖÃÎļþÒÔʹÉèÖÃÉúЧ£º

sudo nginx -s reload

µÇ¼ºó¸´ÖÆ

ÔÚʹÓÃNginxµÄÖض¨ÏòÉèÖþÙÐÐÍøÕ¾Á÷Á¿×ªÒÆʱ £¬ÎÒÃÇ¿ÉÒÔƾ֤ÏÖʵÐèÇóÑ¡ÔñÊʺϵÄÖض¨Ïò¹æÔò £¬²¢Í¨¹ý²âÊÔÈ·±£¹æÔòµÄ׼ȷÐÔ¡£±ðµÄ £¬Ó¦µ±¼á³ÖNginxµÄ°æ±¾Óë×îеÄÎȹ̰汾¼á³ÖÒ»Ö £¬ÒÔ×èÖ¹·ºÆðÒÑÖªµÄÎó²îºÍÇå¾²ÎÊÌâ¡£

×ܽáÆðÀ´ £¬NginxµÄÖض¨ÏòÉèÖÃÄܹ»ºÜºÃµØʵÏÖÍøÕ¾Á÷Á¿×ªÒÆ¡£Í¨¹ýºÏÀíÉèÖÃÖض¨Ïò¹æÔò £¬ÎÒÃÇ¿ÉÒÔ½«Ò»¸öÍøÕ¾µÄÁ÷Á¿ÓÐÑ¡ÔñµØÖض¨Ïòµ½ÁíÒ»¸öÍøÕ¾ £¬ÊµÏÖÁ÷Á¿µÄתÒƺÍÌøת¡£Í¨¹ý±¾ÎÄÌṩµÄʾÀý´úÂëºÍʵսÂÄÀú £¬¶ÁÕß¿ÉÒÔ¸üºÃµØÃ÷È·ºÍÔËÓÃNginxµÄÖض¨Ïò¹¦Ð§¡£

ÒÔÉϾÍÊÇNginxÖض¨ÏòÉèÖÃʵս £¬ÊµÏÖÍøÕ¾Á÷Á¿×ªÒƵÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

13452372176

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

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

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