很多才入门的seo朋友不知道伪静态的几种形式,这里荣帅seo通过zblog的几种伪静态设置方式,告诉大家所有的伪静态设置方式是怎样的?
1.服务器必须支持伪静态
首先在开启伪静态功能前说下,伪静态生效的前提是服务器支持伪静态,如果服务器不支持伪静态设置了也不生效,只能用动态。
2.伪静态的3种形态及命名方式
伪静态总共只有3中,命名方式分别为.htaccess、web.config、httpd.ini这三种,为什么会有3中形态:
其一;服务器分为apache服务和iis服务器,apache服务器用的是.htaccess
其二;另外iis7和iis8用的是web.config
其三;iis6要创建httpd.ini,每种服务器都对应一种命名方式
很多朋友都不清楚这点,下面重庆seo用zblog伪静态为例写出zblog的3种伪静态,以作为借鉴,让其他朋友知道伪静态的原理
3.通过zblog的3中伪静态了解所有的伪静态写法
(1)zblog网站apache服务器的伪静态规则命名和写法
如果你的网站服务器是apache服务器,那么创建一个.htaccess文件,把下面的内容复制进去,然后将.htaccess文件上传到网站根目录下:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
(2)如果你的网站服务器是IIS7或者IIS8,那么创建一个web.config文件,把下面的内容复制进去,然后将web.config文件上传到网站根目录下:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="/ Z-BlogPHP Imported Rule" stopProcessing="true">
<match url="^.*?" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php/{R:0}" />
</rule>
<rule name="/ Z-BlogPHP Imported Rule index.php" stopProcessing="true">
<match url="^index.php/.*?" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" />
</conditions>
<action type="Rewrite" url="index.php/{R:0}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
(3)如果你的网站服务器是IIS6,那么创建一个httpd.ini文件,把下面的内容复制进去,然后将httpd.ini文件上传到网站根目录下:
[ISAPI_Rewrite]
RewriteRule /page_([0-9]*)\.html /index\.php\?page=$1&rewrite=1 [I,L]
RewriteRule /date-([0-9\-]+)(?:_)?([0-9]*)\.html /index\.php\?date=$1&page=$2&rewrite=1 [I,L]
RewriteRule /author-([0-9]+)(?:_)?([0-9]*)\.html /index\.php\?auth=$1&page=$2&rewrite=1 [I,L]
RewriteRule /tags-([0-9]+)(?:_)?([0-9]*)\.html /index\.php\?tags=$1&page=$2&rewrite=1 [I,L]
RewriteRule /category-([0-9]+)(?:_)?([0-9]*)\.html /index\.php\?cate=$1&page=$2&rewrite=1 [I,L]
RewriteRule /post/([0-9]+)\.html(\?.*)? /index\.php\?id=$1&rewrite=1 [I,L]
RewriteRule /([0-9]+)\.html(\?.*)? /index\.php\?id=$1&rewrite=1 [I,L]
4.以上中的httpd.ini有些seo朋友看不懂是怎么回事儿,这个是利用正则表达式写的,不知道的朋友可以在荣帅站内搜索“正则表达式”网站seo优化会给你详解正则表达式的写法和操作。
发表评论 取消回复