您现在的位置: > 首页 > 网站建设 > 服务器
>> 最新教程
>> 热门教程
>> 最新游戏资讯
>> 热门游戏资讯
Apache 2.x 服务器中的URL重写的配置和应用
作者:本站                来自:安迪教程网                 加入时间:08-07-22                进入论坛讨论

  第二:创建一个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("&amp;page=") . '([0-9]+)' . preg_quote("&amp;sort=") . '([a-z]*)' . preg_quote("&amp;order="). '([a-z]*)' . preg_quote("&amp;pp=") . '([0-9]*)' . preg_quote("&amp;daysprune="). '([^"]*)"#',
'#<a ([^>]*)href' . preg_quote("="forumdisplay.php?$session[sessionurl]f=") . '([0-9]+)' . preg_quote("&amp;daysprune=") . '([^"]*)' . preg_quote("&amp;order=") . '([a-z]*)' . preg_quote("&amp;sort=") . '([a-z]*)' . preg_quote("&amp;pp=") . '([0-9]*)' . preg_quote("&amp;page=") . '([0-9]+)"#',
'#<a ([^>]*)href' . preg_quote("="forumdisplay.php?$session[sessionurl]f=") . '([0-9]+)' . preg_quote("&amp;daysprune=") . '([^"^&]*)' . preg_quote("&amp;order=") . '([a-z]*)' . preg_quote("&amp;sort=") . '([a-z]*)"#',
'#<a ([^>]*)href' . preg_quote("="forumdisplay.php?$session[sessionurl]f=") . '([0-9]+)' . preg_quote("&amp;daysprune="). '([^"^&]*)"#',
'#<a ([^>]*)href' . preg_quote("="forumdisplay.php?$session[sessionurl]f=") . '([0-9]+)' . preg_quote("&amp;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("&amp;page=") . '([0-9]*)' . preg_quote("&amp;pp=") . '([0-9]+)"#',
'#<a ([^>]*)href' . preg_quote("="showthread.php?$session[sessionurl]t=") . '([0-9]+)' . preg_quote("&amp;page=") . '([0-9]+)"#',
'#<a ([^>]*)href' . preg_quote("="showthread.php?$session[sessionurl]t=") . '([0-9]+)"#',
'#<a ([^>]*)href' . preg_quote("="showthread.php?$session[sessionurl]goto=lastpost&amp;t=") . '([0-9]+)"#',
'#<a ([^>]*)href' . preg_quote("="showthread.php?$session[sessionurl]goto=newpost&amp;t=") . '([0-9]+)"#',
'#<a ([^>]*)href' . preg_quote("="printthread.php?$session[sessionurl]t=") . '([0-9]+)"#',
'#<a ([^>]*)href' . preg_quote("="sendmessage.php?$session[sessionurl]do=sendtofriend&amp;t=") . '([0-9]+)"#',
'#<a ([^>]*)href' . preg_quote("="showthread.php?$session[sessionurl]t=") . '([0-9]+)' . preg_quote("&amp;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("&amp;page=") . '([0-9]+)' . preg_quote("&amp;pp=") . '([0-9]+)"#',
'#<a ([^>]*)href' . preg_quote("="showpost.php?$session[sessionurl]p=") . '([0-9]+)' . preg_quote("&amp;postcount=") . '([0-9]+)"#',
'#<a ([^>]*)href' . preg_quote("="showthread.php?$session[sessionurl]mode=") . '([a-z]+)' . preg_quote("&amp;t=") . '([0-9]+)"#',
'#<a ([^>]*)href' . preg_quote("="showthread.php?$session[sessionurl]p=") . '([0-9]+)' . preg_quote("&amp;mode=") . '([a-z]+)##',
  
'#<a ([^>]*)href' . preg_quote("="announcement.php?$session[sessionurl]f=") . '([0-9]+)' . preg_quote("&amp;announcementid=") . '([0-9]+)"#',
'#<a ([^>]*)href' . preg_quote("="announcement.php?$session[sessionurl]f=") . '([0-9]+)"#',
  
// sanitizing
'#<a ([^>]*)href=http://tech.ddvip.com/2008-01/"([^"]*)&amp;page=([^"]*).html"#',
'#<a ([^>]*)href=http://tech.ddvip.com/2008-01/"([^"]*)&amp;highlight=([^"]*).html"#',
  
// other
'#<a ([^>]*)href' . preg_quote("="search.php?$session[sessionurl]do=getdaily&amp;f=") . '([0-9]*)"#',
'#<a ([^>]*)href' . preg_quote("="search.php?$session[sessionurl]do=getdaily") . '"#',
'#<a ([^>]*)href' . preg_quote("="search.php?$session[sessionurl]do=process&amp;replyless=1&amp;replylimit=0&amp;dontcache=1&amp;forumchoice=&amp;childforums=1") . '"#',
'#<a ([^>]*)href' . preg_quote("="search.php?$session[sessionurl]do=process&amp;replyless=1&amp;replylimit=0&amp;dontcache=1&amp;forumchoice=") . '([0-9]+)' . preg_quote("&amp;childforums=1") . '"#'
  
);
$replace_array = array(
'<a 1href=http://tech.ddvip.com/2008-01/"forum2-3-4-5-6-7.html"',
'<a 1href=http://tech.ddvip.com/2008-01/"forum2-7-5-4-6-3.html"',
'<a 1href=http://tech.ddvip.com/2008-01/"forum2-3-4-5.html"',
'<a 1href=http://tech.ddvip.com/2008-01/"forum2-3.html"',
'<a 1href=http://tech.ddvip.com/2008-01/"forum2-3.html"',
'<a 1href=http://tech.ddvip.com/2008-01/"forum2.html"',
'<a 1href=http://tech.ddvip.com/2008-01/"thread2-3.html"',
'<a 1href=http://tech.ddvip.com/2008-01/"thread2-3.html"',
'<a 1href=http://tech.ddvip.com/2008-01/"thread2.html"',
'<a 1href=http://tech.ddvip.com/2008-01/"lastpostinthread2.html"',
'<a 1href=http://tech.ddvip.com/2008-01/"newpostinthread2.html"',
'<a 1href=http://tech.ddvip.com/2008-01/"printthread2.html"',
'<a 1href=http://tech.ddvip.com/2008-01/"sendthread2.html"',
'<a 1href=http://tech.ddvip.com/2008-01/"next3tothread2.html"',
'<a 1href=http://tech.ddvip.com/2008-01/"post2.html"',
'<a 1href=http://tech.ddvip.com/2008-01/"post2-3-4.html"',
'<a 1href=http://tech.ddvip.com/2008-01/"post2-3.html"',
'<a 1href=http://tech.ddvip.com/2008-01/"thread3-2.html"',
'<a 1href=http://tech.ddvip.com/2008-01/"post2-3.html#',
  
'<a 1href=http://tech.ddvip.com/2008-01/"announcement2-3.html"',
'<a 1href=http://tech.ddvip.com/2008-01/"announcement2.html"',
  
// sanitizing
'<a 1href=http://tech.ddvip.com/2008-01/"2-3.html"',
'<a 1href=http://tech.ddvip.com/2008-01/"2-3.html"',
  
// other
'<a 1href=http://tech.ddvip.com/2008-01/"getdaily2.html"',
'<a 1href=http://tech.ddvip.com/2008-01/"getdaily.html"',
'<a 1href=http://tech.ddvip.com/2008-01/"unanswered.html"',
'<a 1href=http://tech.ddvip.com/2008-01/"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 > >> >>>
联系方式:QQ:6084884 email:agwcn@126.com 粤ICP备05055782号
本网站中发布的文章只代表发表人的个人观点,不代表安迪教程网网站的立场
copyright© 2000-2004 安迪教程网 All rights reserved agwcn.com