How to convert php dynamic web pages into html when dynamic web pages meet the search engine?
Although dynamic web pages have many advantages over static pages, they have a big hit in search engine search. No matter how many websites, especially corporate websites for marketing purposes, no one wants their web pages to be retrieved by search engines. However, in fact, many content pages designed for dynamic websites cannot be searched by search engines. For more php video tutorials, please follow the public account (if Hong Wang ).
In general, the search engine displays "?" in a dynamic webpage address. The character is regarded as a "stop Mark", and all parameters after it are ignored. For example? For all sub-pages of category = x, the search engine only returns one url, that is, the index. php page. As a result, dynamic web pages are in a dilemma where they cannot be found and searched by search engines, directly losing the opportunity to be discovered by users and a broad market space such as search engines.
Why search engines do not support dynamic web pages
Dynamic web pages are driven by databases, which puts search engines in danger of being stuck in an endless loop by databases in the face of countless URLs. this is what we call spider traps ). In addition, if a spider is trapped by a website, its repeated access requests to the database will also completely paralyze the website server system. In view of this, search engines include "?" No subsequent characters are read.
Convert php to html static page
Although every dynamic page cannot be converted to a static html file, if the website is hosted on the apache server, you only need a simple script to convert most dynamic pages into html files.
1. confirm the php file to be converted to the suffix html
Our goal is to target webpages with more dynamic subpages. Take "index. php? Category = x "as an example. we need to convert the dynamic subpages after" index. php. For example, if there is a subdirectory named "arts and crafts" in the website, the url is "index. php? Category = 1 ". The other subdirectories and the url are only different from the last variable. Therefore, we need to modify the server's open mode when index. php follows the variable.
2. the notification server opens a php file after receiving an html page call request.
We need to place a. htaccess text file in the directory where index. php is located on the server .. The htaccess file is a directory configuration setting file on the apache server. It provides methods for changing the configuration of directories, that is, put a file containing one or more commands in a specific document directory (. to apply to this directory and all its subdirectories .. Htaccess allows you to set the webpage password, set the file that appears when an error occurs, change the homepage file name, prohibit reading the file name, redirect the file to a new one, add the mime category, and disable files in the column directory.
When you need to change the server configuration for the directory without the root permission for the server system, you should use the. htaccess file. If the server administrator is unwilling to modify the configuration frequently, the user can pass. the htaccess file is used to modify the configuration by itself, especially when the isp provides multiple user sites on one machine, and you want to change the configuration by yourself, the part is usually open. the htaccess function is set for the user. For vdeck users, you may need to create a text file and rename it as. htaccess in the management panel. Now we need to specify some variables on the server side. For example, The categorypolicx variable is changed to “directory-x.html, which eliminates the problem that dynamic pages cannot be searched by search engines.
Before creating server variables, create a rewrite engine (url rewriting tool) in the newly created. htaccess file ). You only need to write in the first line of the file
Rewriteengine on
This tells the server to change the processing method of some files. In the next line, you must specify the rewrite rule:
Rewriterule ^ directory-([0-9] *. * index. php? Category = $1 [l, nc]
This command indicates that as long as the request is received from any static webpage with "directory-0" to "directory-9" in the url, the server uses "index. php? The variable address is returned to the caller.
Don't rush to edit the next rewrite rule. we need to test it before changing the actual php page. We can test the above "rewrite rules. First, open a browser window and enter export directory-1.htm.pdf or export directory-1.html in the address bar. if the page we see is "index. php? "Category = 1" indicates that the rewrite rule works normally.
3. let the search engine see our static page
Now, we need to enable the search engine to see the new webpage address that we have changed. So, do you need to submit the website again to the search engine? You don't have to worry about it. you just need to open the php file and edit it. Before that, remember to back up every script to be modified and store it on the hard disk. Then you need to determine the different places of the program that creates and modifies the link address. It is better to make changes at the front end rather than in the background. The php file will get the "index. php?" format from the. htaccess file? Category = x. We need to change these dynamically generated webpage addresses and display them to users and search engines in a static manner. Will all URLs contain "index. php? Replace the categorycategory category with the category directory-category and add the. HTML suffix.
Once the region to be modified is found, check whether there are any errors at any time after the change. If errors are not found in the script, the correction is quite tricky, especially when you are not familiar with php encoding.