Z-Blog classification label static all-Site Solution

Source: Internet
Author: User
Z-Blog has implemented static homepage and article pages, which can generate HTML files. However, the classification page, Tags page, archive page, and author page of the system are not static, this article describes a very simple solution to automatically generate static HT for each category page, archive page, and Tags... "> <LINKhref =" http://www.php100.com//statics/sty

Z-Blog has implemented static homepage and article pages, which can generate HTML files. However, the classification page, Tags page, archive page, and author page of the system are not static, this article describes a very simple solution to automatically generate static HTML pages for each category page, archive page, and Tags, so that you can migrate your website to a host that does not support ASP, such as Apache.

The category page, Tags page, archive page, and author page of Z-Blog call catalog. asp file. Therefore, when you call this file, an HTML file for this page is automatically generated. If a visitor reads this file repeatedly, a static file can be used directly at the beginning of the file within a certain period of time to save system resources.

The specific modification method is to first create a directory cat under the root, then use the editor to open the catalog. asp file under the root directory of Z-Blog, and add the following code at the beginning of the file:

Dim objFSO
Dim objFile
Dim strFileName
Dim strFileTime
Dim isBuildFile
If Request. QueryString ("cate") <> "then
If Request. QueryString ("page") <> "" then
StrFileName = "cate" + "_" + Request. QueryString ("cate") + "_" + Request. QueryString ("page") + ". html"
Else
StrFileName = "cate" + "_" + Request. QueryString ("cate") + ". html"
End if
Elseif Request. QueryString ("tags") <> "then
If Request. QueryString ("page") <> "" then
StrFileName = "tags" + "_" + Request. QueryString ("tags") + "_" + Request. QueryString ("page") + ". html"
Else
StrFileName = "tags" + "_" + Request. QueryString ("tags") + ". html"
End if
Elseif Request. QueryString ("auth") <> "then
If Request. QueryString ("page") <> "" then
StrFileName = "auth" + "_" + Request. QueryString ("auth") + "_" + Request. QueryString ("page") + ". html"
Else
StrFileName = "auth" + "_" + Request. QueryString ("auth") + ". html"
End if
Elseif Request. QueryString ("date") <> "then
If Request. QueryString ("page") <> "" then
StrFileName = "date" + "_" + Request. QueryString ("date") + "_" + Request. QueryString ("page") + ". html"
Else
StrFileName = "date" + "_" + Request. QueryString ("date") + ". html"
End if
Elseif Request. QueryString ("page") <> "then
StrFileName = "default" + "_" + Request. QueryString ("page") + ". html"
Else
StrFileName = "default_1" + ". html"
End If
IsBuildFile = False
Set objFSO = CreateObject ("Scripting. FileSystemObject ")
If objFSO. FileExists (Server. MapPath (strFileName) Then
Set objFile = objFSO. GetFile (Server. MapPath (strFileName ))
StrFileTime = objFile. DateLastModified
Set objFile = Nothing
If datediff ("h", strFileTime, Now ()> 1 Then
IsBuildFile = True
Else
Server. Transfer strFileName
Response. End
End If
Else
IsBuildFile = True
End If
Set objFSO = Nothing

Find a line in Response. Write ArtList.html and add the following code to it:

If isBuildFile Then
ArtList. FileName = strFileName
ArtList. Directory = "cat"
ArtList. Save
End if

In this way, the system will automatically generate static HTML files for all dynamic pages, and will not generate them again within one hour. if there are still calls during this period, the static HTML files will be automatically loaded, to save system resources.

After this processing, all types of Z-Blog and Tags can generate static HTML pages.

After static, you can put all the Z-Blog websites on the PHP + Apache host. The specific method is to configure the Apache host, use php to parse asp, edit the catalog. asp file, and modify its code as follows:

If (isset ($ _ GET ['Cate']) {
If (isset ($ _ GET ['Page']) {
$ StrFileName = "cate _". strip_tags (stripslashes (trim ($ _ GET ['Cate']). "_". strip_tags (stripslashes (trim ($ _ GET ['Page']). ". html ";
} Else {
$ StrFileName = "cate _". strip_tags (stripslashes (trim ($ _ GET ['Cate']). ". html ";
}
} Else if (isset ($ _ GET ['tags']) {
If (isset ($ _ GET ['Page']) {
$ StrFileName = "tags _". strip_tags (stripslashes (trim ($ _ GET ['tags']). "_". strip_tags (stripslashes (trim ($ _ GET ['Page']). ". html ";
} Else {
$ StrFileName = "tags _". strip_tags (stripslashes (trim ($ _ GET ['tags']). ". html ";
}
} Else if (isset ($ _ GET ['auth ']) {
If (isset ($ _ GET ['Page']) {
$ StrFileName = "auth _". strip_tags (stripslashes (trim ($ _ GET ['auth ']). "_". strip_tags (stripslashes (trim ($ _ GET ['Page']). ". html ";
} Else {
$ StrFileName = "auth _". strip_tags (stripslashes (trim ($ _ GET ['auth']). ". html ";
}
} Else if (isset ($ _ GET ['Date']) {
If (isset ($ _ GET ['Page']) {
$ StrFileName = "date _". strip_tags (stripslashes (trim ($ _ GET ['Date']). "_". strip_tags (stripslashes (trim ($ _ GET ['Page']). ". html ";
} Else {
$ StrFileName = "date _". strip_tags (stripslashes (trim ($ _ GET ['Date']). ". html ";
}
} Else if (isset ($ _ GET ['Page']) {
$ StrFileName = "default _". strip_tags (stripslashes (trim ($ _ GET ['Page']). ". html ";
} Else {
$ StrFileName = "../default.html ";
}
Define ("HTML_FILE", dirname (_ FILE _). "/". $ strFileName );
If (file_exists (HTML_FILE )){
Echo (file_get_contents (HTML_FILE ));
Exit (0 );
} Else {
Exit (0 );
}
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.