How to convert PHP Dynamic Web pages into HTML

Source: Internet
Author: User
Tags root access
When a dynamic Web page encounters a search engine

Although dynamic Web pages have many advantages over static pages, they touch a big nail in search engine retrieval. No matter any website, especially those marketing-based corporate websites, no one would want their pages to be retrieved by search engines. But in fact, the dynamic site design of many content pages can not be searched by search engines. For more PHP Video tutorials Please follow the public number (Johon net).

In general, the search engine will put the "?" appearing in the Dynamic web address. The character is treated as a stop tag, and all parameters after it are ignored. For example, to "Index.php?category=x" all the sub-pages, the search engine finally retrieved the URL only one, that is index.php this page. In this way, the Dynamic Web page is caught in the search engine can not be found and retrieval of embarrassment, directly lost the opportunity to be discovered by users and search engines such a broad market space.

Why the search engine does not support Dynamic Web pages

Dynamic Web pages are driven by databases, which makes it dangerous for search engines to be trapped in a dead loop with countless URLs, which is what we call spider traps (spiders traps). And once the spider is covered by the Web site, its repeated requests for access to the database can also cause a complete paralysis of the Web server system. In view of this, the search engine for the Dynamic Web page contains "?" in the URL. All subsequent characters are not read.

PHP converted to HTML static page

While there is no guarantee that each dynamic page will be converted to a static HTML file, if the site resides on the Apache server, you can convert most of the dynamic pages into HTML files with just one simple little foot.

1. Determine the PHP file that needs to be converted to HTML suffix

Our goal is to include pages with more dynamic sub-pages in their name. Taking "Index.php?category=x" as an example, we need to convert the dynamic sub-page after "index.php". For example, if the site has a subdirectory named "Arts and Crafts", the URL is "Index.php?category=1", and the other subdirectories and this URL are only different on the last variable, So we need to modify the way the server opens it when it follows the variable after index.php.

2. Notifies the server to open a PHP file after accepting a call request from an HTML page

We need to place a. htaccess text file in the directory where index.php resides on the server. The. htaccess file is a directory configuration settings file on the Apache server that provides a way to change the configuration for the directory. That is, place a file (. htaccess file) that contains one or more instructions in a particular document directory, to act on this directory and all of its subdirectories: Htaccess features include setting the Web page password, setting the file that appears when an error occurs, changing the home page file name, preventing the file name from being read, Re-directing files, adding MIME categories, preventing files under the column directory, and so on.

You should use the. htaccess file when you need to change the configuration of the server for the directory and do not have root access to the server system. If the server administrator is reluctant to modify the configuration frequently, you can allow the user to modify the configuration through the. htaccess file itself, especially if the ISP provides multiple user sites on a single machine, and you want users to be able to change the configuration themselves. Generally open section. The Htaccess function is set to the user. For Vdeck users, you might need to create a text file and then rename it to. htaccess in the admin panel. Now we need to specify some variables on the server side. For example, I need to change the "? category=x" variable to "directory-x.html", which will eliminate the problem that dynamic pages cannot be retrieved by search engines.

Before we start creating server variables, we need to create a rewrite engine (URL rewrite tool) in this new. htaccess file. Only need to write on the first line of the file

Rewriteengine on

This is tantamount to telling the server that we want to change the way some files are handled. The next line will specify the rewrite rule:

Rewriterule ^directory-([0-9]*.* index.php?category=$1 [L,NC]

This instruction indicates that the server will return the "index.php variable" address to the calling user as soon as it receives a page call request from any static Web page that contains "directory-0" to "directory-9" in the URL.

Don't worry about editing the next rewrite rule, we need to test it before changing the actual PHP page. We can test the "rewrite rule" above. First open a new browser window, enter "directory-1.htm" or "directory-1.html" in the address bar, if we see the page displayed as "Index.php?category=1" indicates that the rewrite rule is working properly.

3. Let the search engine see our static page

Now, we need to let the search engine see the new web address that we have "makeover". So, is it necessary to quickly submit the site to the search engine again? Not so hard, we just have to open the php file to edit it. But before you do, remember to make a backup of each script you want to modify and store it on your hard disk. Then you need to determine the different places to create the program that changed the link address. It is best to make changes in the front end rather than in the background. The PHP file will get information such as "Index.php?category=x" from the. htaccess file. We need to change these dynamically generated page addresses and display them to users and search engines in a static page address. Replace the section with "index.php?category=" in all URLs with "directory-" and add an. html suffix.

Once you have found the area to be modified, check for errors at any time after the change. If there are errors in the script that are not found, it is tricky to correct them, especially if you are unfamiliar with PHP coding.

  • 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.