URL重写之伪静态规则:
URL重写是一个比较大的概念,说起来比较简单,是指通过技术手段将一条链接改写成另一条链接的过程。
URL重写有复杂的规则,不过,在SEM中,大多数时候并不需要完全会写,只要读懂相应开源程序的官方说明即可,通常造做一遍即可。
在SEM中,用到URL重写的地方除了URL canonicalization(URL规范化)就是伪静态了。
URL重写之伪静态规则举例说明:
根据常用的SEM常用网站程序四大员简述一下,仅指Apache环境下的.htaccess文件规则,网站空间为Windows的可以去官方网站自行学习或者在Google和百度搜索。
Wordpress伪静态规则:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
Discuz BBS伪静态规则:
RewriteEngine On
RewriteBase /
RewriteRule ^archiver/((fid|tid)-[\w\-]+\.html)$ archiver/index.php?$1
RewriteRule ^forum-([0-9]+)-([0-9]+)\.html$ forumdisplay.php?fid=$1&page=$2
RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ viewthread.php?tid=$1&extra=page\%3D$3&page=$2
RewriteRule ^space-(username|uid)-(.+)\.html$ space.php?$1=$2
RewriteRule ^tag-(.+)\.html$ tag.php?name=$1
Discuz uchome伪静态规则:
RewriteEngine On
RewriteBase /
RewriteRule ^(space|network)\-(.+)\.html$ $1.php?rewrite=$2 [L]
RewriteRule ^(space|network)\.html$ $1.php [L]
RewriteRule ^([0-9]+)$ space.php?uid=$1 [L]
ShopEx伪静态规则:
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} \.(html|xml|json|htm|php|php2|php3|php4|php5|phtml|pwml|inc|asp|aspx|ascx|jsp|cfm|cfc|pl|cgi|shtml|shtm|phtm)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L]
简单解释一下:
RewriteEngine On意为开启伪静态引擎。
RewriteBase / 意为网站程序所处位置,默认斜杠为根目录,根据实际情况填写。
RewriteRule 意为伪静态重写规则,早做即可。
根据程序将规则写于记事本,上传服务器网站空间根目录下,更名为.htaccess即可。
URL重写之伪静态规则简述:
伪静态规则生效需要网站空间和网站程序的共同配合方可。伪静态在SEM建站体系中是很重要的一环,在建站之初就需要考虑好,选好空间,选好程序,较为流行的开源程序通常都考虑过伪静态的问题,可以在官方找到伪静态规则,如果选用小公司开发的程序,请事先问清楚关于伪静态的问题,如果过于复杂或者根本不支持,则最好换用其它程序。
作者:杨灿灿@SEM界 SEM第一版 2009-10-28
SEM-ALL,中国SEM学习运营第一品牌
本文SEM-ALL版权所有,未经批准转载必究。