Static pseudo-Static precedence
What are the best solutions to solve static, pseudo-static priority issues?
System: Linux Apache php/5.2.17
Now the server is using the. htaccess rewrite address to do pseudo-static, using the cache. However, it is often more than the space quotient of CPU limit, has recently been two times the space quotient has been forced to stop.
Now want to change most of the page to pure static, only pagination also retains pseudo-static.
Now you want to be able to link directly to the "Pure static HTML" page when the "Pure static HTML" page exists, and pseudo-static if the "pure static HTML" page does not exist.
However, we know that the "pure static" page cannot be accessed under the specification of pseudo-static rules and will always be linked to the corresponding PHP page execution.
Query Baidu, see there are said to use different suffixes to distinguish between pure static and pseudo-static, such as:. htm. html
This can be achieved, but to modify many of the templates in the. html, very troublesome, here to ask the great God there is no better solution.
Hope that the great God is not so generous!
It's humbly!
Reply to discussion (solution)
Resolving priority issues with different extensions of. htm. html, which brings up another problem, is the status code 302 problem
302 The search engine is unfriendly, will cause the search engine misunderstanding (has URL normalization and the URL hijacking problem, may be judged by the search engine as suspicious turn, even think is cheating "excerpt from XXX Blog")
. htm do pseudo-static, when the user clicks xxx/xx.htm come in the corresponding xx.php will execute, first determine whether xx.html exists and not expire, if not read data and template generated corresponding xx.html page, if it is direct location to xx.html. This is the location to turn, resulting in 302 errors, so ...
So ask the great gods, is there a good solution?
The. htaccess rewrite address should be resolved. If not found, the next rule. Not really, write the rules for 404.
Anyway, you have to decide whether there is a static page, you must use the PHP program. Anyway, Apache doesn't care about this.
if (!file_exists (' xxx/xx.htm ') | | (Time ()-filemtime (' xxx/xx.htm ')) (>3600)) {
Code generation Automation program, save as Xxx/xx.htm
}else{
File_get_contents (xxx/xx.htm);
}
Or more from the source of work, reduce include,require, reasonable use of unset (); Merge the same code for function () calls, and so on.
In addition, you can consider changing space.
1, if there is no suffix, it is obviously not true static. The trouble is also need to be modified
Moreover, the URL of the pseudo-static page should be generated by the function, if you do not do so, then you should resolutely correct it.
2. Common rewrite rules are
Rewritecond%{request_filename}!-f
If the file exists, the file is accessed directly without the following rewriterule.
3, if the real existence of the. htm will also be processed by PHP, then I do not know what your "static" refers to what
Thank you, Mr. Xu.
I never knew.
Rewritecond%{request_filename}!-f
Rewritecond%{request_filename}!-d
The role
Now I know.
Thank you! Knot Stickers!