WEB开发网      婵犵數濞€濞佳囧磹婵犳艾鐤炬い鎰堕檮閸嬬喐銇勯弽銊с€掗梻鍕閺岋箑螣娓氼垱笑闂佽姘﹂褔婀佸┑鐘诧工妤犲憡绂嶉崜褏纾奸弶鍫涘妼缁楁岸鏌熷畡鐗堝殗闁诡喒鏅犲畷褰掝敃閵堝棙顔忔繝鐢靛仦閸ㄥ爼骞愰幘顔肩;闁规崘绉ぐ鎺撳亹闁绘垶锕╁Λ鍕⒑閹肩偛濡奸悗娑掓櫇缁顓兼径妯绘櫇闂佹寧绻傞弻濠囨晝閸屾稓鍘甸柣搴㈢⊕閿氶柣蹇ョ稻缁绘繃绻濋崘銊т紝闂佽鍨伴崯鏉戠暦閻旂⒈鏁傞柛鈾€鏅欑槐妯衡攽閻愬樊鍤熷┑顔藉劤铻為柛鏇ㄥ墯閸欏繘鏌嶉崫鍕櫣缂佲偓婢跺绠鹃柟瀛樼箘閿涘秵顨ラ悙顏勭伈闁诡喖缍婂畷鎯邦槻婵℃彃顭烽弻娑㈠Ω閵夈儺鍔夌紓浣稿€哥粔褰掑极閹剧粯鏅搁柨鐕傛嫹 ---闂傚倷鐒︾€笛兠洪埡鍛闁跨噦鎷�
开发学院服务器WEB服务器Apache Apache 2.x 服务器中的URL重写的配置和应用 阅读

Apache 2.x 服务器中的URL重写的配置和应用

 2008-01-10 00:00:00 来源:WEB开发网 闂傚倷绶氬ḿ褍螞閹绢喖绠柨鐕傛嫹闂傚倷绀侀幉锟犲垂閻㈠灚宕查柟鎵閸庡秵銇勯幒鎴濃偓鐢稿磻閹炬枼妲堟繛鍡楃С濞岊亞绱撻崒姘扁枌闁瑰嚖鎷�婵犵數濮幏鍐川椤撴繄鎹曢梻渚€娼уú銈吤洪妸鈺佺劦妞ゆ帊鑳堕埊鏇㈡煏閸モ晛浠х紒杈╁仱閺佹捇鏁撻敓锟�闂傚倷绶氬ḿ褍螞閹绢喖绠柨鐕傛嫹  闂傚倷鑳舵灙缂佺粯顨呴埢宥夊即閵忕姵鐎梺缁樺姇閻忔氨鈧凹鍓熷娲垂椤曞懎鍓伴梺閫炲苯澧紒澶婄秺瀵濡歌閸嬫捇妫冨☉娆忔殘闂佷紮缍€娴滎剟鍩€椤掑倹鏆柛瀣躬瀹曚即寮借閺嗭箓鏌ㄩ悤鍌涘
核心提示: 第二:创建一个xml文件;比如您可以用 vbburlhack.xml ,在这个文件内贴上如下内容;<?xml version="1.0" encoding="UTF-8"?><product productid="danis_s

第二:创建一个xml文件;

比如您可以用 vbburlhack.xml ,在这个文件内贴上如下内容;

<?xml version="1.0" encoding="UTF-8"?>
  
<product productid="danis_seo_optimization" active="1">
<title>Danis Seo Optimization</title>
<description><![CDATA[This is a very quick 'n' simple vBulletin SEO hack. It's easy to apply and it's the one I have been using here on DaniWeb for the past couple of months. I was going to wait until we went vB 3.5 to release it but I might as well do so now ... Disclaim]]></description>
<version>1.0</version>
<codes>
</codes>
<templates>
</templates>
<plugins>
<plugin active="1">
<title><![CDATA[Dani's SEO optimization]]></title>
<hookname>global_complete</hookname>
<phpcode><![CDATA[// do Dani's SEO optimization
global $session;
  
$search_array = array(
'#<a ([^>]*)href' . preg_quote("="forumdisplay.php?$session[sessionurl]f=") . '([0-9]+)' . preg_quote("&page=") . '([0-9]+)' . preg_quote("&sort=") . '([a-z]*)' . preg_quote("&order="). '([a-z]*)' . preg_quote("&pp=") . '([0-9]*)' . preg_quote("&daysprune="). '([^"]*)"#',
'#<a ([^>]*)href' . preg_quote("="forumdisplay.php?$session[sessionurl]f=") . '([0-9]+)' . preg_quote("&daysprune=") . '([^"]*)' . preg_quote("&order=") . '([a-z]*)' . preg_quote("&sort=") . '([a-z]*)' . preg_quote("&pp=") . '([0-9]*)' . preg_quote("&page=") . '([0-9]+)"#',
'#<a ([^>]*)href' . preg_quote("="forumdisplay.php?$session[sessionurl]f=") . '([0-9]+)' . preg_quote("&daysprune=") . '([^"^&]*)' . preg_quote("&order=") . '([a-z]*)' . preg_quote("&sort=") . '([a-z]*)"#',
'#<a ([^>]*)href' . preg_quote("="forumdisplay.php?$session[sessionurl]f=") . '([0-9]+)' . preg_quote("&daysprune="). '([^"^&]*)"#',
'#<a ([^>]*)href' . preg_quote("="forumdisplay.php?$session[sessionurl]f=") . '([0-9]+)' . preg_quote("&page=") . '([0-9]+)"#',
'#<a ([^>]*)href' . preg_quote("="forumdisplay.php?$session[sessionurl]f=") . '([0-9]+)"#',
'#<a ([^>]*)href' . preg_quote("="showthread.php?$session[sessionurl]t=") . '([0-9]+)' . preg_quote("&page=") . '([0-9]*)' . preg_quote("&pp=") . '([0-9]+)"#',
'#<a ([^>]*)href' . preg_quote("="showthread.php?$session[sessionurl]t=") . '([0-9]+)' . preg_quote("&page=") . '([0-9]+)"#',
'#<a ([^>]*)href' . preg_quote("="showthread.php?$session[sessionurl]t=") . '([0-9]+)"#',
'#<a ([^>]*)href' . preg_quote("="showthread.php?$session[sessionurl]goto=lastpost&t=") . '([0-9]+)"#',
'#<a ([^>]*)href' . preg_quote("="showthread.php?$session[sessionurl]goto=newpost&t=") . '([0-9]+)"#',
'#<a ([^>]*)href' . preg_quote("="printthread.php?$session[sessionurl]t=") . '([0-9]+)"#',
'#<a ([^>]*)href' . preg_quote("="sendmessage.php?$session[sessionurl]do=sendtofriend&t=") . '([0-9]+)"#',
'#<a ([^>]*)href' . preg_quote("="showthread.php?$session[sessionurl]t=") . '([0-9]+)' . preg_quote("&goto=next"). '([a-z]+)"#',
'#<a ([^>]*)href' . preg_quote("="showthread.php?$session[sessionurl]p=") . '([0-9]+)"#',
'#<a ([^>]*)href' . preg_quote("="showthread.php?$session[sessionurl]p=") . '([0-9]+)' . preg_quote("&page=") . '([0-9]+)' . preg_quote("&pp=") . '([0-9]+)"#',
'#<a ([^>]*)href' . preg_quote("="showpost.php?$session[sessionurl]p=") . '([0-9]+)' . preg_quote("&postcount=") . '([0-9]+)"#',
'#<a ([^>]*)href' . preg_quote("="showthread.php?$session[sessionurl]mode=") . '([a-z]+)' . preg_quote("&t=") . '([0-9]+)"#',
'#<a ([^>]*)href' . preg_quote("="showthread.php?$session[sessionurl]p=") . '([0-9]+)' . preg_quote("&mode=") . '([a-z]+)##',
  
'#<a ([^>]*)href' . preg_quote("="announcement.php?$session[sessionurl]f=") . '([0-9]+)' . preg_quote("&announcementid=") . '([0-9]+)"#',
'#<a ([^>]*)href' . preg_quote("="announcement.php?$session[sessionurl]f=") . '([0-9]+)"#',
  
// sanitizing
'#<a ([^>]*)href="([^"]*)&page=([^"]*).html"#',
'#<a ([^>]*)href="([^"]*)&highlight=([^"]*).html"#',
  
// other
'#<a ([^>]*)href' . preg_quote("="search.php?$session[sessionurl]do=getdaily&f=") . '([0-9]*)"#',
'#<a ([^>]*)href' . preg_quote("="search.php?$session[sessionurl]do=getdaily") . '"#',
'#<a ([^>]*)href' . preg_quote("="search.php?$session[sessionurl]do=process&replyless=1&replylimit=0&dontcache=1&forumchoice=&childforums=1") . '"#',
'#<a ([^>]*)href' . preg_quote("="search.php?$session[sessionurl]do=process&replyless=1&replylimit=0&dontcache=1&forumchoice=") . '([0-9]+)' . preg_quote("&childforums=1") . '"#'
  
);
$replace_array = array(
'<a 1href="forum2-3-4-5-6-7.html"',
'<a 1href="forum2-7-5-4-6-3.html"',
'<a 1href="forum2-3-4-5.html"',
'<a 1href="forum2-3.html"',
'<a 1href="forum2-3.html"',
'<a 1href="forum2.html"',
'<a 1href="thread2-3.html"',
'<a 1href="thread2-3.html"',
'<a 1href="thread2.html"',
'<a 1href="lastpostinthread2.html"',
'<a 1href="newpostinthread2.html"',
'<a 1href="printthread2.html"',
'<a 1href="sendthread2.html"',
'<a 1href="next3tothread2.html"',
'<a 1href="post2.html"',
'<a 1href="post2-3-4.html"',
'<a 1href="post2-3.html"',
'<a 1href="thread3-2.html"',
'<a 1href="post2-3.html#',
  
'<a 1href="announcement2-3.html"',
'<a 1href="announcement2.html"',
  
// sanitizing
'<a 1href="2-3.html"',
'<a 1href="2-3.html"',
  
// other
'<a 1href="getdaily2.html"',
'<a 1href="getdaily.html"',
'<a 1href="unanswered.html"',
'<a 1href="unanswered2.html"'
  
);
$output = preg_replace($search_array, $replace_array, $output);]]></phpcode>
</plugin>
</plugins>
<phrases>
</phrases>
<options>
</options>
</product>

第三:从vbb后台登录,点击产品,然后导入这个vbburlhack.xml 文件;

只要导入,就能成功了。效果可参见 http://www.linuxsir.org/bbs

注意:如果出现错误,就是你的.htaccess 没放对地方,或者权限不对。如果有问题,不要来问我,这个插件不是我写的,是洋人写的,我只是搬过来应用。呵。。。。出问题就去找他们吧。谢谢了~~~~

2.2 drupal 的URL地址重写设置;

drupal就比较简单了,不象vbb一样,要自己来弄,drupal程序本身就提供了.htaccess 文件。在安装程序的目录里就有。我们只是设置一下就能用了。要通过管理员帐号登录。如果您安装的了中文模块的支持,就是定义干净的URL,他要我们来测试是否能用。如果测试通过,打开就是了。只是点鼠标。如果你没有通过,说明你把.htaccess 文件给丢了,下载一份drupal,把这个文件复制过去就行了。注意是.htaccess ,前面有个小点……

3、关于本文;

本文是在维护 LinuxSir.Org 服务器的过程中,想到Clean URL是比较重要的, 因为这样Google就可以更加有效率的收录网页了。我们可以利用Google的搜索找到我们所需要的东西。在一定程度上,缓解了 LinuxSir.Org 服务器的压力。我们把搜索、邮局让Google来托管,可以减轻我们维护服务器的工作量,感谢Google!

上一页  1 2 3 4 

Tags:Apache 服务器 URL

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接