您好,欢迎光临! 推荐您使用Chrome浏览器访问本站。

网站静态化处理的几种方法

网站静态化处理的几种方法

1. 使用IIS_ReWrite 静态化处理,适合PHP、ASP、ASP.NET 程序。
A. isapi_rewrite.isapi_rewrite分精简(lite)和完全(full)版.精简版不支持对每个虚拟主机站点进行重写,只能进行全局处理,精简版下载地址ISAPI_Rewrite 2.7 For IIS 。
B. 打开IIS,选择网站,右键菜单属性,添加过滤器。
C. 打开文件:开始菜单->程序->Helicon->ISAPI_Rewrite->httpd.ini
D. 将RewriteRule /user/(\d+).htm /user.asp\?id=$1 [I,O] 加入内容中。
E. 在浏览器地址栏输入:/user/1.htm 页面将指向/user.asp?id=1。

2. 使用虚拟主机的ASP 网站,需要使用404 错误操作实现静态化。
A. 下载404 处理页面。404_Rewrite_GB2312.rar
B. 解压后将Rewrite.asp、error.asp 放在网站的根目录。
C. 设置网站自定义错误信息如图:
D. 在error.asp 里添加处理命令:
Call ParaseUrl(“/(\d+).htm”,”/user.asp?User=$1″)
E. 在需要静态化的实例user.asp 页面中添加代码:
引用文件
response.write ”

  • Para=” & session(“Para”) ‘变量是通过Session 传递
    ‘原来使用request(“user”)获得参数的命令,需要修改成request_(“user”)调用
    response.write “
  • request_(“”User””)=” & request_(“User”)
    ‘原用request.querystring (“user”)获得参数命令,修改为request__.querystring (“user”)调用
    response.write “
  • request__.querystring(“”User””)=” & request__.querystring(“User”)
    %>
    F. 在地址栏输入/1.htm ,实际调用/user.asp?user=1

3. 使用asp.net 开发的网页程序,使用URLRewriter.dll 实现静态化。
A. 下载URLRewriter.rar,解压后放在/bin/目录下
B. 将URLRewriter.rar 加入工程引用。
C. 配置IIS 站点,将扩展名为html 指向处理程序aspnet_isapi.dll。
IIS 站点->属性->主目录->配置->添加
可执行文件和aspx 处理相同,都是 c:\windows\microsoft.net\framework\v2.0.50727\aspnet_isapi.dll
特别注意,一定不要选择检查文件是否存在。
D. 在web.config 中添加配置内容,压缩包里有。

 

~/(\d*).html
~/user/default.aspx?link=$1

 

E. 在地址栏输入http://localhost/1.html 指向http://localhost/user/default.aspx?link=1

4. 基于Apache HTTP Server 静态化Apache Web Server 的配置(conf/httpd.conf )
A. 在httpd.conf 文件中查找LoadModule rewrite_module modules/mod_rewrite.so
通常该行被注释,去掉“#”。如果没有就增加该行。
B. 加入代码:

RewriteEngine On
RewriteRule ^/([0-9]+).html$ /user.php?user=$1

C. 如果网站使用通过虚拟主机来定义,请务必加到虚拟主机配置文件.htccess 中去,否则可能无法使用。
D. 重启Apache,重新载入配置。
E. 在地址栏输入http://localhost/1.html ,实际指向http://localhost/user.php?user=1

5. 静态化后文件格式
链接静态化后可以是html 文件,也可以是目录,通常目录的权重大于文件的权重,可以在搜索引擎中获得更好的排名。
例如:优化前:http://www.xxxxxx.com/user.asp?id=1
优化后文件:http://www.xxxxxx.com/user/1.html
目录:http://www.xxxxxx.com/user/1/
同等条件下http://www.xxxxx.com/user/1/ 有更高的优先权。

您可能也喜欢