Home >CMS Tutorial >WordPress >What should I do if WordPress pages are static and static files are not generated?

What should I do if WordPress pages are static and static files are not generated?

王林
王林Original
2019-11-07 10:59:162614browse

What should I do if WordPress pages are static and static files are not generated?

Page staticization problem

We must first download the cos-html-cache 2.7.3 page staticization plug-in

1. Search the cos-html-cache plug-in on the plug-in installation page and install

2. Create an html folder in the root directory with permission 777

3. Create the index.bak file in the root directory , Permission 666

4. Modify the fixed connection format to a custom structure,/html/%post_id%_%postname%.html

5. Activate the plug-in

6. Modify the site's default homepage order and add a line to .htaccess:

DirectoryIndex index.html index.htm index.php index.cgi

7. Modify the theme search box code. In the searchform.php file, replace the following code:

action="<?php echo esc_url( home_url( / ) ); ?>"

with:

action="<?php echo esc_url( home_url( /index.php ) ); ?>"

Check, log out, revisit the page, generate the html file in the html directory, and contain the string 337178340620b33435651b1a697f415dThe installation is successful.

The problem that static files cannot be generated

Because the DOCUMENT_ROOT defined by some servers is inconsistent with the directory path of the virtual space, cos-html-cahce cannot find the correct one Directory to generate html. For example, this is the case with 000webhost's server.

There is a line in the cos-html-cache.php file:

$path = $_SERVER[&#39;DOCUMENT_ROOT&#39;]."/";

The solution can be to use a php script to test the space path of your host, and then change the value of $path to the space root The directory path is enough, you can create a php file and write the following code.

<?php echo "SeverPath: ".dirname(__FILE__); echo "
"; $path = $_SERVER[&#39;DOCUMENT_<div
style="display: none"><A title="how to increase vertical jump" href="https://www.jb51.net/">how
to increase vertical jump</A>
ROOT&#39;]."/"; echo "DOCUMENT_ROOT: ".$path; ?>

Then upload to the root directory of the space, access the script file, compare and check the path of DOCUMENT_ROOT and the space, if they are inconsistent, just modify the value of $path. For example, when accessing: http://localhost/root_test.php, the return result is as follows:

SeverPath: /home/a4675762/public_html
DOCUMENT_ROOT: /usr/local/apache/htdocs/

You can see that the two paths are completely different, then modify $path to:

$path = "/home/a4675762/public_html/";

Log out of the blog (you must log out before you can generate an html static page), then visit the page again, and the html should be generated normally.

Recommended tutorial: wordpress tutorial

The above is the detailed content of What should I do if WordPress pages are static and static files are not generated?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn