Ò»Ö±ÔÚ×ophpµÄ¿ª¢¹¤×÷.ÔÚ¿ª¢µÄ¹ý³ÌÖÐÀÏÔç¾ÍÌý˵ÁË¡°Î±¾²Ì¬¡±Õaһ˵¡£µ«ÊÇһֱûÓжÔÆa½øÐÐÁ˽a¡£½ñÌiͨ¹ý±¾ÆªÎÄÕÂ×ÐϸѧϰÏ¡£
Ê×ÏÈ£¬Ê²Ã´ÊÇα¾²Ì¬£º
α¾²Ì¬ÓÖÃuURLÖØд£¬ÊǶ¯Ì¬µÄÍøÖ¿´ÆðÀ´Ïñ¾²Ì¬µÄÍøÖ¡£»»¾a»°Ëµ¾ÍÊÇ£¬¶¯Ì¬Íøҳͨ¹ýÖØд URL ½¨ÊµÏÖÈ¥µo¶¯Ì¬ÍøÒ³µÄ²ÎÊý£¬µ«ÔÚʵ¼ÊµÄÍøҳĿ¼Öв¢Ã»ÓбØҪʵÏÖ´aeÔÚÖØдµÄÒ³Ãae¡£
1.¼i²aApacheÊÇ*ñÖ§³Ömod_rewrite
ͨ¹ýphpÌa¹(C)µÄphpinfo()º¯Êý²e¿´»*¾³ÅaÖã¬Í¨¹ýCtrl+F²eÕÒµ½¡°Loaded Modules¡±£¬ÆaÖÐÁгoÁËËuÓÐ
apache2handlerÒѾ¿ªÆoµÄÄ£¿e£¬Èç¹uÀiÃae°uÀ¨¡°mod_rewrite¡±£¬ÔoÒѾ֧³Ö£¬²»ÔÙÐeÒª¼ÌÐøÉeÖá£
Èç¹uûÓпªÆo¡°mod_rewrite¡±£¬Ôo´o¿ªÄ¿Â¼ ÄuµÄapache°²×°Ä¿Â¼¡°/apache/conf/¡± Ï嵀 httpd.conf ÎÄ
¼þ£¬Í¨¹ýCtrl+F²eÕÒµ½¡°LoadModule rewrite_module¡±£¬½«Ç°ÃaeµÄ¡±#¡±ºÅɾ³ý¼´¿É¡£
Èç¹uûÓвeÕÒµ½£¬Ôoµ½¡°LoadModule¡± ÇøÓo£¬ÔÚ×iºoÒ»ÐмÓÈe¡°LoadModule rewrite_module modules/mod_rewrite.so¡±£¨±ØÑ¡¶ÀÕ¼Ò»ÐУ(C)£¬È»ºoÖØÆoapache*þÎñÆ÷¼´¿É¡£
2.ÔÚhttpd.confÖÐÅaÖÃÐeÄaÖ÷»u
Include conf/extra/httpd-vhosts.conf
3.httpd_vhosts.confÎļþÖУ¬ÅaÖÃÏaÓ¦µÄÑ¡Ïi.Ïeϸ½²½a
<VirtualHost *:80>
DocumentRoot "C:/myenv/apache/htdocs/static3"
ServerName www.hsp.com
<Directory "C:/myenv/apache/htdocs/static3">
#Deny from All 403´iÎoÌaʾ
Allow from All
#Èç¹uÎļþĿ¼ÔÚapacheĿ¼ÍaÃae£¬×¢Ê͵ooptinos Ôo£¬²»ÄÜÁбi.
options +Indexes
#ÏÂÃaeÕa¸o±iʾ¿ÉÒÔÈ¥¶ÁÈ¡ .htaccessÎļþ,Ò²¿ÉÒÔÖ±½ÓÔÚÐeÄaÖ÷»uÖÐÅaÖÃ.
Allowoverride All
RewriteEngine On
RewriteRule news-id(\d+).html$ error.php?id=$1
#ÕaÀi¿ÉÒÔÉeÖöa¸oÖØдµÄ¹aeÔo
#RewriteRule news-id.html$ error.php
</Directory>
</VirtualHost>
4.ÔÚÏaÓ¦µÄĿ¼Ï±aд.htaccess ÖØд¹aeÔo
Àý×Ó£º
<IfModule rewrite_module>
RewriteEngine On
RewriteRule news-id(\d+).html$ show.php?id=$1
#ÕaÀi¿ÉÒÔÉeÖöa¸oÖØдµÄ¹aeÔo
#RewriteRule news-id.html$ error.php
</IfModule>
Èç¹uÔÚlinuxÏ¿ÉÒÔÖ±½Ó´´½¨,
Èç¹uÊÇÔÚwindowsƽ̨Ï£¬ÓüÇʱ¾´´½¨Ò»¸oÎļþ,±ÈÈçabc.txt,È»ºoÁi´aeΪ .htaccessÎļþ¼´¿É
5.ÖØд¹aeÔo£¬Ò²¿ÉÒÔÖ±½ÓÔÚÅaÖÃÐeÄaÖ÷»uµÄ
¶¯Ì¬¡¢¾²Ì¬¡¢Î±¾²Ì¬Ö®¼aµÄÀuÓe±×£¨Ð£(C)
*¶¯Ì¬ÍøÖ
**
Ê×ÏÈ£¬¶¯Ì¬ÍøÖÄ¿Ç°¶ÔÓÚGoogleÀ´Ëµ£¬¡°²»Äܱ»×¥È¡¡±µÄ˵¨ÊÇ´iÎoµÄ£¬GoogleÄܹ»ºÜºÃµÄ´¦Ài¶¯Ì¬ÍøÖ²¢Ë³Àuץȡ£»Æa´Î¡°²ÎÊý²»Äܳ¬¹ý3¸o¡±µÄ˵¨Ò²²»ÕýÈ£¬GoogleÄܹ»×¥È¡²ÎÊý³¬¹ý3¸oµÄ¶¯Ì¬ÍøÖ£¬²»¹ý£¬ÎªÁ˱ÜÃaURLÌ«³¤Ó¦¾¡Á¿¼oÉÙ²ÎÊý¡£
Æa´Î£¬¶¯Ì¬ÍøÖÓÐÆaÒ»¶¨µÄÓÅÊÆ£¬ÒÔÉÏÃaeËu˵µÄ news.php£¿lang=cn&class;=1&id;=2 ΪÀý£¬ÍøÖÖеIJÎÊý׼ȵĸaeËßGoogle£¬´ËURLÄÚÈÝÓiÑÔΪcn¡¢Á¥ÊoÓÚÖÀa1¡¢ÄÚÈÝIDΪ2£¬¸u±aÓÚGoogle¶ÔÄÚÈݵÄʶ±ð´¦Ài¡£
×iºo£¬¶¯Ì¬ÍøÖ*Ó¦¾¡Á¿¾«¼o£¬ÌرðÊÇ»a»°±eʶ£¨sid£(C)ºÍ²eѯ£¨query£(C)²ÎÊý£¬ÈÝÒ×Ôi³É´oÁ¿ÏaͬҳÃae¡£
**¾²Ì¬ÍøÖ***
Ê×ÏÈ£¬¾²Ì¬ÍøÖ*¾ßÓеľø¶ÔÓÅÊÆÊÇÆaÃ÷Îu£¬/product/nokia/n95.htmlºÍ/about.html¿ÉÒÔºÜÈÝÒ×±»Ài½a£¬´Ó¶øÔÚËÑË÷½a¹uÖпÉÄܵa»÷Á¿Ïa¶Ô½Ï¸ß¡£
Æa´Î£¬¾²Ì¬ÍøÖδ±Ø¾ÍÊÇ×iºÃµÄÍøÖÐÎʽ£¬ÉÏÊo¶¯Ì¬ÍøÖÖÐ˵µ½£¬¶¯Ì¬ÍøÖÄܹ»¸aeËßGoogleÒ»Ð(C)¿ÉÒÔʶ±ðµÄ²ÎÊý£¬¶ø¾²Ì¬ÍøÖÈç¹uÎĵµ²¼Öò»¹»Ç¡µ±£¨È磺¹ýÓÚ±aƽ»¯£¬½«HTMLÎĵµÈ«ÅÔÚ¸uĿ¼Ï£(C)¼°ÆaËuÒoËØ£¬´¶ø²»È羲̬ÍøÖΪGoogleÌa¹(C)µÄ²Î¿¼ÐÅÏ¢*a¸»¡£
×iºo£¬˜Ë¼Êñ¾oµÃGoogle´ËÎÄÖÐÊÇñÓÐÆaÒþ²Øº¬Òa£¿¡°¸uдËÖÖÀaÐÍÍøÖµÄÒ³Ãae»a±È½ÏºÄÑʱ¼a£¬ÓÈÆaÊǵ±ÐÅÏ¢Á¿Ôo³¤ºÜ¿iʱ£¬ÒoΪÿһ¸oµ¥¶ÀµÄÒ³Ãae¶¼±ØÐe¸u¸Ä±aÒe´uÂe¡£¡±ËaÈ»Ëu˵µÄÊÇÍøÕ¾£¬µ«ÔÚGoogleϵͳÖÐÊÇ*ñͬÑu´aeÔÚÕaÑuµÄÎÊÌaÄØ£¿
**α¾²Ì¬ÍøÖ***
Ê×ÏÈ£¬Î±¾²Ì¬ÍøÖ²»ÄÜÈö¯Ì¬ÍøÖ¡°¾²Ì¬»¯¡±£¬Î±¾²Ì¬½o½oÊǶԶ¯Ì¬ÍøÖ*µÄÒ»¸oÖØд£¬Google²»»aÈÏΪα¾²Ì¬¾ÍÊÇHTMLÎĵµ¡£
Æa´Î£¬Î±¾²Ì¬¿ÉÈ¡£¬µ«Ó¦°ÑÖØÐÄÅÔÚÈ¥³ýÈßÓa²ÎÊý¡¢¹ae¶URL¡¢¾¡¿ÉÄܵıÜÃaÖظ´Ò³ÉÏ¡£
×iºo£¬Î±¾²Ì¬ÓкܴoDZ´oΣÏÕ£¬×iºÃÔÚ¶ÔÍøվϵͳ¡¢ÍøÕ¾½a¹¹¡¢ÄÚÈÝ*Ö²¼¡¢²ÎÊýÒaÒaÊiϤµÄÇe¿oÏÂʹÓá£
ÔÚдα¾²Ì¬¹aeÔoʱ£¬Ó¦±£ÁoÓмÛÖµµÄ²ÎÊý£¬²»Òª½«ÓмÛÖµµÄ²ÎÊýÈ«²¿¾«¼oµo£¬ÈçÇ°ÃaeÀý×ÓÖÐµÄ news.php£¿lang=cn&class;=1&id;=2 ×iºÃÖØдΪ news-cn-class1-id2.html£¬¶ø²»Êǹý*ݾ«¼oÖØдΪ news-2.html¡£
ÔÙ¾ÍÊÇα¾²Ì¬ÖÐÒ»¶¨²»ÄÜ°uº¬»a»°±eʶ£¨sid£(C)ºÍ²eѯ£¨query£(C)²ÎÊý£¬/product.asp£¿sid=98971298178906&id;=1234 ÕaÑuµÄ¶¯Ì¬ÍøÖ£¬ÆaÖеÄsid±¾À´GoogleÄܹ»Ê¶±ð²¢ÆÁ±Î£¬µ«Èç¹uÖØдΪ /product/98971298178906/1234£¬Google²»µ«Îިʶ±ð£¬»¹ÔÚÕuÕ¾ÖÐÔi³ÉÎÞÏÞÖظ´Ò³Ãae£¨Ã¿¸o»a»°¶¼»a²uÉuÒ»¸oеĻa»°ID£(C)¡£