What are the best solutions to solve static and pseudo-static priority problems? Static pseudo-static priority
What are the best solutions to solve static and pseudo-static priority problems?
System: Linux Apache PHP/5.2.17
Now the server uses. htaccess to rewrite the address for pseudo-static and cache. However, it often exceeds the cpu limit of the space provider, which has been forced to shut down twice recently.
Now, I want to change most pages to pure static, and only the pages still retain pseudo static.
Now we want to directly link to the "pure static html" page if the "pure static html" page exists. if the "pure static html" page does not exist, we will use pseudo static.
However, we know that the "pure static" page cannot be accessed under the standard with pseudo-static rules and will always be linked to the corresponding php page for execution.
When querying Baidu, we can see that different suffixes are used to distinguish between pure static and pseudo static, such as. htm. html.
This can be achieved, but it is very troublesome to modify the .html in many templates. could you please tell me if there is a better solution.
Hope you will not be enlightened!
Thank you!
Reply to discussion (solution)
When different extensions of .htm. html are used to solve the priority problem, there will be another problem, that is, the status code 302 problem.
302 unfriendly to search engines may lead to misunderstanding of search engines (problems with URL standardization and URL hijacking may be identified as suspicious redirection by search engines, I even think it is cheating [from xxx blog ])
. Htm is pseudo-static. when the user clicks xxx/xx.htm, the corresponding xx. php will be executed. This is the location redirection, resulting in a 302 error, so ......
So, do you have any good solutions?
The. htaccess rewrite address should be fixed. If no rule is found, the next rule is displayed. I can't do it. write a rule for 404.
In any case, you must use the PHP program to determine whether a static page exists. In short, apache does not care about this.
If (! File_exists ('XXX/xx.htm') | (time ()-filemtime ('XXX/xx.htm')> 3600 )){
// Code generation automatic program, saved as xxx/xx.htm
} Else {
// File_get_contents (xxx/xx.htm );
}
Let's move on to the source code to reduce include, require, and reasonably use unset (); merge the same code for function () calls, and so on.
In addition, you can consider changing the space.
1. if there is no suffix, it is obviously not true or static. It also needs to be modified.
What's more, the url of the pseudo-static page should be generated by the function. if you do not do this, you should resolutely correct it.
2. common rewrite rules include
RewriteCond % {REQUEST_FILENAME }! -F
If the file exists, access the file directly without the following RewriteRule.
3. if php processing is required for all existing. htm instances, I don't know what your "static" means.
Thank you, Miss Xu.
Never know
RewriteCond % {REQUEST_FILENAME }! -F
RewriteCond % {REQUEST_FILENAME }! -D
Function
Now I know.
Thank you! Close the post!