Windows系统下面实现伪静态的方法有很多,但一般采用安装伪静态组件来实现。本文将以wordpress的自定义固定链接(即实现伪静态)为例,讲述如何在windows的环境下实现伪静态。 1、我们必须先要明白为什么我们需要使用伪静态? 这个主要是从SEO的角度取考虑的。从多次实践中证明,搜索引擎蜘蛛比较青睐于静态页面(相对另外一种是动态页面)的静态URL,而静态页面又分为真静态和伪静态。真静态是服务器端真正存在一个静态页面,但静态页面具有更新困难、存储量大等缺点未必受人欢迎。于是,人们往往采用伪静态的方法用于网站以更好地获得好的搜索引擎排名。 2、安装IIS的URL REWRITE组件 点击这里下载IIS Rewrite组件 把压缩包解压,把里面的dll文件复制到C:WINDOWSsystem32inetsrv目录。在 IIS 管理器里选择网站,右键选择“属性”。打开属性窗口,选择ISAPI筛选器,点击添加,筛选器名称填“Rewrite”,可执行文件填上刚刚下载的dll路径,“C:WINDOWSsystem32inetsrvrewrite.dll”如下图所示: 点击确认,重启IIS服务器!!到这里,组件安装完成。 3、让wordpress完美实现自定义固定链接(即wordpress伪静态)。 进入wordpress后台/设置/固定链接,常用设置选择自定义结构。如果你非要选前面几个结构,那你没必要看本文,那不需要服务器支持伪静态。看本站的URL结构,我写的是: /%category%/%postname%/ 。至于为什么这样写,它对SEO有什么好处,你可以去问谷哥或度娘,不解析。确保站点根目录的.htaccess文件存在,并且可写。点击保存更改。此时,wordpress应该有修改你的.htaccess文件,看看我的.htaccess文件的内容: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> 然后,IIS是不支持.htaccess文件的,我们还需要在站点根目录添加一个httpd.ini文件,看我的伪静态规则。 [ISAPI_Rewrite] # 3600 = 1 hour CacheClockRate 3600 RepeatLimit 32 # Protect httpd.ini and httpd.parse.errors files # from accessing through HTTP # Rules to ensure that normal content gets through RewriteRule /software-files/(.*) /software-files/$1 [L] RewriteRule /images/(.*) /images/$1 [L] RewriteRule /sitemap.xml /sitemap.xml [L] RewriteRule /favicon.ico /favicon.ico [L] # For file-based wordpress content (i.e. theme), admin, etc. RewriteRule /wp-(.*) /wp-$1 [L] # For normal wordpress content, via index.php RewriteRule ^/$ /index.php [L] RewriteRule /(.*) /index.php/$1 [L] 上面两个文件在不同的网站程序有不同的伪静态规则,请安装自己的需要编写。 完成。到前台查看网站页面。如果没有出现404错误,那就表示你配置成功了。 4、关于IIS7的伪静态实现 另外,有些人使用的是IIS7,实现伪静态就更简单了,不需要.htaccess和httpd.ini文件,直接把伪静态规则写到站点根目录的web.config配置文件里就行了。 wordpress完全支持IIS7的伪静态,在上面第3步点击保存更改的时候,wordpress会自动生成web.config文件,并写上相应规则。看我在IIS7下面产生的文件。 <?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="wordpress" patternSyntax="Wildcard"> <match url="*"/> <conditions> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/> </conditions> <action type="Rewrite" url="index.php"/> </rule></rules> </rewrite> </system.webServer> </configuration> 附:WordPress常见固定链接结构 1)/%postname%/ or /%postname%.html 2)/%year%/%monthnum%/%postname%/ or /%year%/%monthnum%/%postname%.html 3)/post/%postname%.html 4)/%category%/%postname%/ or /%category%/%postname%.html 现在,你是不是手痒痒想去操作一下啊? 转自:http://www.uglycolor.net/develop/win2003-iis6-rewrite-wordpress/ Loading... Windows系统下面实现伪静态的方法有很多,但一般采用安装伪静态组件来实现。本文将以wordpress的自定义固定链接(即实现伪静态)为例,讲述如何在windows的环境下实现伪静态。 <h3>1、我们必须先要明白为什么我们需要使用伪静态?</h3> 这个主要是从SEO的角度取考虑的。从多次实践中证明,搜索引擎蜘蛛比较青睐于静态页面(相对另外一种是动态页面)的静态URL,而静态页面又分为真静态和伪静态。真静态是服务器端真正存在一个静态页面,但静态页面具有更新困难、存储量大等缺点未必受人欢迎。于是,人们往往采用伪静态的方法用于网站以更好地获得好的搜索引擎排名。<!--more--> <h3>2、安装IIS的URL REWRITE组件</h3> <span class="external-link"><a class="no-external-link" href="http://www.uglycolor.net/usr/uploads/2012/02/rewrite.rar" target="_blank"><i data-feather="external-link"></i>点击这里下载IIS Rewrite组件</a></span> 把压缩包解压,把里面的dll文件复制到C:WINDOWSsystem32inetsrv目录。在 IIS 管理器里选择网站,右键选择“属性”。打开属性窗口,选择ISAPI筛选器,点击添加,筛选器名称填“Rewrite”,可执行文件填上刚刚下载的dll路径,“C:WINDOWSsystem32inetsrvrewrite.dll”如下图所示: <span class="external-link"><a class="no-external-link" href="http://www.xiaoten.com/usr/uploads/2012/04/11.jpg" target="_blank"><i data-feather="external-link"></i><img class="attachment-full size-full" src="http://www.xiaoten.com/usr/uploads/2012/04/11.jpg" sizes="(max-width: 472px) 100vw, 472px" srcset="http://www.xiaoten.com/usr/uploads/2012/04/11-300x288.jpg 300w, http://www.xiaoten.com/usr/uploads/2012/04/11.jpg 472w" alt="11" width="472" height="453" style=""></a></span> 点击确认,重启IIS服务器!!到这里,组件安装完成。 3、让wordpress完美实现自定义固定链接(即wordpress伪静态)。 进入wordpress后台/设置/固定链接,常用设置选择自定义结构。如果你非要选前面几个结构,那你没必要看本文,那不需要服务器支持伪静态。看本站的URL结构,我写的是: /%category%/%postname%/ 。至于为什么这样写,它对SEO有什么好处,你可以去问谷哥或度娘,不解析。确保站点根目录的.htaccess文件存在,并且可写。点击保存更改。此时,wordpress应该有修改你的.htaccess文件,看看我的.htaccess文件的内容: <blockquote> <div class="source" style="font-family: '[object HTMLOptionElement]', Consolas, 'Lucida Console', 'Courier New'; color: #000000;"><span style="color: #000080; font-weight: bold;"><IfModule</span> <span style="color: #ff0000;">mod_rewrite</span><span style="color: #a61717; background-color: #e3d2d2;">.</span><span style="color: #ff0000;">c</span><span style="color: #000080; font-weight: bold;">></span> RewriteEngine On RewriteBase / RewriteRule ^index.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] <span style="color: #000080; font-weight: bold;"></IfModule></span></div></blockquote> 然后,IIS是不支持.htaccess文件的,我们还需要在站点根目录添加一个httpd.ini文件,看我的伪静态规则。 <blockquote> <div class="source" style="font-family: '[object HTMLOptionElement]', Consolas, 'Lucida Console', 'Courier New'; color: #000000;">[ISAPI_Rewrite] # 3600 = 1 hour CacheClockRate 3600 RepeatLimit 32 # Protect httpd.ini and httpd.parse.errors files # from accessing through HTTP # Rules to ensure that normal content gets through RewriteRule /software-files/(.*) /software-files/$1 [L] RewriteRule /images/(.*) /images/$1 [L] RewriteRule /sitemap.xml /sitemap.xml [L] RewriteRule /favicon.ico /favicon.ico [L] # For file-based wordpress content (i.e. theme), admin, etc. RewriteRule /wp-(.*) /wp-$1 [L] # For normal wordpress content, via index.php RewriteRule ^/$ /index.php [L] RewriteRule /(.*) /index.php/$1 [L]</div></blockquote> 上面两个文件在不同的网站程序有不同的伪静态规则,请安装自己的需要编写。 完成。到前台查看网站页面。如果没有出现404错误,那就表示你配置成功了。 4、关于IIS7的伪静态实现 另外,有些人使用的是IIS7,实现伪静态就更简单了,不需要.htaccess和httpd.ini文件,直接把伪静态规则写到站点根目录的web.config配置文件里就行了。 wordpress完全支持IIS7的伪静态,在上面第3步点击保存更改的时候,wordpress会自动生成web.config文件,并写上相应规则。看我在IIS7下面产生的文件。 <blockquote> <div class="source" style="font-family: '[object HTMLOptionElement]', Consolas, 'Lucida Console', 'Courier New'; color: #000000;"><span style="color: #008080;"><?</span><span style="color: #000000;">xml</span> <span style="color: #000000;">version</span><span style="color: #000000;">=</span><span style="color: #0000ff;">"1.0"</span> <span style="color: #000000;">encoding</span><span style="color: #000000;">=</span><span style="color: #0000ff;">"UTF-8"</span><span style="color: #008080;">?></span> <span style="color: #000080; font-weight: bold;"><configuration></span> <span style="color: #000080; font-weight: bold;"><system</span><span style="color: #a61717; background-color: #e3d2d2;">.</span><span style="color: #ff0000;">webServer</span><span style="color: #000080; font-weight: bold;">></span> <span style="color: #000080; font-weight: bold;"><rewrite></span> <span style="color: #000080; font-weight: bold;"><rules></span> <span style="color: #000080; font-weight: bold;"><rule</span> <span style="color: #ff0000;">name=</span><span style="color: #0000ff;">"wordpress"</span> <span style="color: #ff0000;">patternSyntax=</span><span style="color: #0000ff;">"Wildcard"</span><span style="color: #000080; font-weight: bold;">></span> <span style="color: #000080; font-weight: bold;"><match</span> <span style="color: #ff0000;">url=</span><span style="color: #0000ff;">"*"</span><span style="color: #000080; font-weight: bold;">/></span> <span style="color: #000080; font-weight: bold;"><conditions></span> <span style="color: #000080; font-weight: bold;"><add</span> <span style="color: #ff0000;">input=</span><span style="color: #0000ff;">"{REQUEST_FILENAME}"</span> <span style="color: #ff0000;">matchType=</span><span style="color: #0000ff;">"IsFile"</span> <span style="color: #ff0000;">negate=</span><span style="color: #0000ff;">"true"</span><span style="color: #000080; font-weight: bold;">/></span> <span style="color: #000080; font-weight: bold;"><add</span> <span style="color: #ff0000;">input=</span><span style="color: #0000ff;">"{REQUEST_FILENAME}"</span> <span style="color: #ff0000;">matchType=</span><span style="color: #0000ff;">"IsDirectory"</span> <span style="color: #ff0000;">negate=</span><span style="color: #0000ff;">"true"</span><span style="color: #000080; font-weight: bold;">/></span> <span style="color: #000080; font-weight: bold;"></conditions></span> <span style="color: #000080; font-weight: bold;"><action</span> <span style="color: #ff0000;">type=</span><span style="color: #0000ff;">"Rewrite"</span> <span style="color: #ff0000;">url=</span><span style="color: #0000ff;">"index.php"</span><span style="color: #000080; font-weight: bold;">/></span> <span style="color: #000080; font-weight: bold;"></rule></rules></span> <span style="color: #000080; font-weight: bold;"></rewrite></span> <span style="color: #a61717; background-color: #e3d2d2;"><</span>/system.webServer> <span style="color: #000080; font-weight: bold;"></configuration></span></div></blockquote> 附:WordPress常见固定链接结构 1)/%postname%/ or /%postname%.html 2)/%year%/%monthnum%/%postname%/ or /%year%/%monthnum%/%postname%.html 3)/post/%postname%.html 4)/%category%/%postname%/ or /%category%/%postname%.html 现在,你是不是手痒痒想去操作一下啊? 转自:<span class="external-link"><a class="no-external-link" href="http://www.uglycolor.net/develop/win2003-iis6-rewrite-wordpress/" target="_blank"><i data-feather="external-link"></i>http://www.uglycolor.net/develop/win2003-iis6-rewrite-wordpress/</a></span> © 允许规范转载 赞 如果觉得我的文章对你有用,请随意赞赏