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

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