PHP implementation of page static

Source: Internet
Author: User

1, through the buffer to achieve the need to use file_put_contents Ob_get_clean () and other built-in functions Ob_start (); include "filterpost.html"; $mtime = Filemtime ("./ Filterpost.html ");//Here you can determine whether a file exists and expires, then do a cache or generate a static file operation $pagecache = Str_replace (' submit2 ', ' Login ', ob_get_contents () );//Replace the cached contents with Ob_end_clean (); Echo $mtime; Echo $pageCache; 2, through $_server[' path_info ' to achieve echo ' <pre> ';p rint_r ($_server);p reg_match ('/^\/(\d+) \ (\d+) \.html/', $_server[ ' Path_info '], $arr);p Rint_r ($arr); 3, through the Apache configuration to achieve the need to open the rewrite rewrite module through the rewrite to configure Vhost
Rewriteengine on
Rewritecond%{document_root}%{request_filename}!-d
Rewritecond%{document_root}%{request_filename}!-f
Rewriterule ^/detail/([0-9]*). html$/detail.php?id=$1
If the folder and its files do not exist under the server, then rewrite the definition to/detail.php

If there is no 1.html under the detail folder then rewrite the definition to./detail.php 4, configure rewrite ^/detail/(\d+) \.html$/detail.php in nginx.conf via Nginx configuration? Id=$1 last;

PHP implementation of page static

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.