尊龙凯时人生就是博

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¡¢ÍøÕ¾µØͼ