最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
apache的rewrite伪静态实现自动生成html静态化
时间:2022-07-02 10:42:52 编辑:袖梨 来源:一聚教程网
所有的链接都使用的是/article_view_6.html 第一次执行,用的是rewrite,然后生成了article_view_6.html这个文件,第二次访问。apache就直接使用article_view_6.html这个静态页面了
下面自己写的一个.htaccess文件,主要的作用就是rewrite静态化,如果html文件存在,则直接用,不使用伪静态(不执行php教程),后台如果对文章、首页或是列表页做了更改,只需把相应的html文件删除就行了,无需重新生成。
代码如下 | 复制代码 |
02 RewriteEngine on 03 #rewrite规则 04 RewriteCond %{REQUEST_FILENAME} !-d 05 RewriteCond %{REQUEST_FILENAME} !-f 06 RewriteRule ^article_view_([0-9]+).html$ ?m=article&a=view&1=$1 [L] 07 08 #去掉index.php 框架中需要使用 09 RewriteCond %{REQUEST_FILENAME} !-d 10 RewriteCond %{REQUEST_FILENAME} !-f 11 RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] 12 13
|
02 RewriteEngine on
03 #rewrite规则
04 RewriteCond %{REQUEST_FILENAME} !-d
05 RewriteCond %{REQUEST_FILENAME} !-f
06 RewriteRule ^article_view_([0-9]+).html$ ?m=article&a=view&1=$1 [L]
07
08 #去掉index.php 框架中需要使用
09 RewriteCond %{REQUEST_FILENAME} !-d
10 RewriteCond %{REQUEST_FILENAME} !-f
11 RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
12
13
使用方法
代码如下 | 复制代码 |
02 require_once("html.class.php"); 03 $html=new html(); 04 /* 05 这里是执行php文件。 06 */ 07 08 //成生html文件,应该本句应放最后一行。 09 $html->writehtml(); 10 ?> |
相关文章
- 庄园领主休闲流城镇如何规划 04-30
- 原神4.6林尼配队推荐 04-30
- 射雕手游郊狼横道任务怎么做 04-30
- mxc官网交易所 04-30
- 明日方舟新六星射手维什戴尔怎么获取 明日方舟新六星射手维什戴尔获取方法 04-30
- 原神遗迹龙兽速刷路线分享 原神遗迹龙兽boss在哪 04-30