×ðÁú¿­Ê±

NginxÖØдURLÉèÖÃʵս £¬ÓÅ»¯ÍøվĿ¼½á¹¹ºÍSEO

nginxÖØдurlÉèÖÃʵս £¬ÓÅ»¯ÍøվĿ¼½á¹¹ºÍseo

СÐò£º

NginxÊÇÒ»¿î¸ßÐÔÄܵÄWebЧÀÍÆ÷ºÍ·´ÏòÊðÀíЧÀÍÆ÷ £¬±»ÆÕ±éÓÃÓÚ¹¹½¨ºÍÓÅ»¯ÍøÕ¾¡£ÆäÖÐÒ»¸öÖ÷ÒªµÄ¹¦Ð§ÊÇURLÖØд £¬Í¨¹ýÉèÖÃNginxµÄURLÖØд¹æÔò £¬ÎÒÃÇ¿ÉÒÔÓÅ»¯ÍøÕ¾µÄĿ¼½á¹¹ £¬Ìá¸ßÓû§ÌåÑéºÍSEO¡£

Ò»¡¢ÎªÊ²Ã´ÐèÒªÖØдURL

ÃÀ»¯URL£ºÓѺõÄURL¹ØÓÚÓû§À´ËµÔ½·¢Ò׶Á¡¢Ò×¼Ç £¬Ò²¸üÓÐÎüÒýÁ¦¡£Í¨¹ýURLÖØд £¬ÎÒÃÇ¿ÉÒÔ½«¶¯Ì¬URLת»»Îª¾²Ì¬URL £¬´Ó¶øÌáÉýÓû§ÌåÑé¡£

ÓÅ»¯ÍøվĿ¼½á¹¹£ºÍ¨¹ýURLÖØд £¬ÎÒÃÇ¿ÉÒÔµ÷½âÍøÕ¾µÄĿ¼½á¹¹ £¬½«URL·¾¶²ã¼¶¼ò»¯ £¬Ìá¸ßÍøÕ¾µÄ¿É¶ÁÐÔºÍά»¤ÐÔ¡£

¸ÄÉÆSEOЧ¹û£ºËÑË÷ÒýÇæ¸üϲ»¶¾²Ì¬URL £¬Í¨¹ýURLÖØд £¬ÎÒÃÇ¿ÉÒÔ½«¶¯Ì¬URLת»»Îª¾²Ì¬URL £¬Ìá¸ßÍøÕ¾ÔÚËÑË÷ÒýÇæÅÅÃûÖеÄȨÖØ¡£

¶þ¡¢NginxÖеÄURLÖØдÉèÖÃ

NginxÌṩÁËrewriteÖ¸ÁîÀ´ÉèÖÃURLÖØд¹æÔò¡£ÏÂÃæÊÇÒ»¸ö¼òÆÓµÄʾÀý£º

server {
    listen 80;
    server_name example.com;

    location / {
        if (!-e $request_filename){
            rewrite ^/(.*)$ /index.php?/$1 last;
        }
    }

    location ~ .php {
        fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
        # ÆäËûfastcgiÏà¹ØÉèÖÃ
    }
}

µÇ¼ºó¸´ÖÆ

ÉÏÊöÉèÖÃÖÐ £¬ÎÒÃÇʹÓÃÁËrewriteÖ¸ÁîÀ´½ç˵URLÖØд¹æÔò¡£ÈôÊÇÇëÇóµÄÎļþ²»±£´æ £¬Ôò½«ÇëÇóÖØдµ½index.phpÎļþ £¬²¢½«ÇëÇóµÄ·¾¶×÷Ϊ²ÎÊýת´ï¸øindex.php¡£

Èý¡¢URLÖØдµÄ³£¼ûÓ¦Óó¡¾°

Òþ²ØÎļþÀ©Õ¹Ãû£º

¼ÙÉè×ðÁú¿­Ê±ÍøÕ¾ÓÐÒ»¸ö¶¯Ì¬Ò³Ãæ £¬URLΪ£ºhttp://example.com/article?id=1 £¬ÎÒÃÇ¿ÉÒÔͨ¹ýURLÖØд½«Æäת»»Îª¾²Ì¬URL£ºhttp://example.com/article/1¡£

server {
    listen 80;
    server_name example.com;

    location / {
        if (!-e $request_filename){
            rewrite ^/article/(d+)$ /article?id=$1 last;
        }
    }

    location ~ .php {
        fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
        # ÆäËûfastcgiÏà¹ØÉèÖÃ
    }
}

µÇ¼ºó¸´ÖÆ

¼ò»¯URLĿ¼½á¹¹£º

¼ÙÉè×ðÁú¿­Ê±ÍøÕ¾ÓÐÒ»¸öĿ¼½á¹¹Îª£ºhttp://example.com/archive/year/month/date/title £¬ÎÒÃÇ¿ÉÒÔͨ¹ýURLÖØд½«Æä¼ò»¯Îª£ºhttp://example.com/title¡£

server {
    listen 80;
    server_name example.com;

    location / {
        if (!-e $request_filename){
            rewrite ^/(d+)/(d+)/(d+)/(.*)$ /$4 last;
        }
    }

    location ~ .php {
        fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
        # ÆäËûfastcgiÏà¹ØÉèÖÃ
    }
}

µÇ¼ºó¸´ÖÆ

301Öض¨Ïò£º

ͨ¹ýURLÖØд £¬ÎÒÃÇ¿ÉÒÔ½«¾ÉµÄURLÖض¨Ïòµ½ÐµÄURL £¬¼á³ÖÔ­ÓÐÍøÕ¾µÄSEOȨÖØ¡£

server {
    listen 80;
    server_name example.com;

    location / {
        if ($uri ~ ^/old-url$){
            rewrite ^(.*)$ /new-url permanent;
        }
    }

    location ~ .php {
        fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
        # ÆäËûfastcgiÏà¹ØÉèÖÃ
    }
}

µÇ¼ºó¸´ÖÆ

ËÄ¡¢URLÖØдÉèÖõÄ×¢ÖØÊÂÏî

×èÖ¹ÎÞÏÞÑ­»·£º

µ±ÉèÖÃURLÖØд¹æÔòʱ £¬Òª×¢ÖØ×èÖ¹·ºÆðÎÞÏÞÑ­»·µÄÇéÐΡ£Ê¹ÓÃlast±ê¼Ç £¬¿ÉÒÔÈ·±£Ö»Æ¥ÅäÒ»´ÎÖØд¹æÔò¡£

Ö»¹ÜʹÓÃÕýÔò±í´ïʽ£º

ÕýÔò±í´ïʽ¿ÉÒÔ¸üÎÞаµØÆ¥ÅäºÍת»»URL £¬¿ÉÒÔƾ֤ÐèÇó¾ÙÐнøÒ»²½Ð޸ĺ͵÷½â¡£

Ïêϸ³¡¾°ÏêϸÆÊÎö£º

²î±ðµÄÍøÕ¾¿ÉÄÜÓвî±ðµÄURLÖØдÐèÇó £¬ÏêϸµÄÖØд¹æÔòҪƾ֤ÏÖʵÐèÇó¾ÙÐе÷½âºÍÓÅ»¯¡£

Îå¡¢½áÂÛ

ͨ¹ýºÏÀíÉèÖÃNginxµÄURLÖØд¹æÔò £¬ÎÒÃÇ¿ÉÒÔÓÅ»¯ÍøÕ¾µÄĿ¼½á¹¹ £¬Ìá¸ßÓû§ÌåÑéºÍSEOЧ¹û¡£ÔÚÏÖʵӦÓÃÖÐ £¬ÎÒÃÇҪƾ֤ÏêϸµÄÐèÇó¾ÙÐе÷½âºÍÓÅ»¯ £¬È·±£URLÖØдµÄÎȹ̺ͺÏÀíÐÔ¡£

²Î¿¼×ÊÁÏ£º

Nginx rewrite module documentation: http://nginx.org/en/docs/http/ngx_http_rewrite_module.html

Nginx Beginner’s Guide: https://www.nginx.com/resources/glossary/rewrite/

ÒÔÉϾÍÊÇNginxÖØдURLÉèÖÃʵս £¬ÓÅ»¯ÍøվĿ¼½á¹¹ºÍSEOµÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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