html如何实现伪静态化
时间:
阅读:266
html如何实现伪静态化
最佳回答
伪静态实现的原理就是 index.php?act=about&cid=1 将这种形式的动态路径用 about-1.html 这种形式输出,根据不同的服务器环境,配置方法也不太一样,PHP+iis6的话就要配置httpd.ini文件,php+iis7就要配置web.config,PHP+apache就要配置.htaccess文件
.htaccess规则示例:
RewriteEngine on
RewriteRule ^/?(index|guestbook|online).html$ index.php [L]
RewriteRule ^/?(eindex).html$ index.php?act=$1 [L]
RewriteRule ^/?(index|guestbook|online)-([0-9]+).html$ index.php?p=$2 [L]
RewriteRule ^/?([a-z0-9]+)_([0-9]+).html$ index.php?act=$1&id=$2 [L]
RewriteRule ^/?([a-z0-9]+)-([0-9]+).html$ index.php?act=$1&cid=$2 [L]
RewriteRule ^/?([a-z0-9]+)-([0-9]+)-([0-9]+).html$ index.php?act=$1&cid=$2&p=$3 [L]
httpd.ini示例:
[ISAPI_Rewrite]
RepeatLimit 32
# Block external access to the httpd.ini and httpd.parse.errors files
RewriteRule /httpd(?:.ini|.parse.errors).* / [F,I,O]
# Block external access to the Helper ISAPI Extension
RewriteRule .*.isrwhlp / [F,I,O]
RewriteRule ^/(index|guestbook|online).html$ /$1.php
RewriteRule ^/(eindex).html$ /index.php?act=$1
RewriteRule ^/(index|guestbook|online)-([0-9]+).html$ /$1.php?p=$2
RewriteRule ^/([a-z0-9]+)_([0-9]+).html$ /index.php?act=$1&id=$2
RewriteRule ^/([a-z0-9]+)-([0-9]+).html$ /index.php?act=$1&cid=$2
RewriteRule ^/([a-z0-9]+)-([0-9]+)-([0-9]+).html$ /index.php?act=$1&cid=$2&p=$3
.htaccess规则示例:
RewriteEngine on
RewriteRule ^/?(index|guestbook|online).html$ index.php [L]
RewriteRule ^/?(eindex).html$ index.php?act=$1 [L]
RewriteRule ^/?(index|guestbook|online)-([0-9]+).html$ index.php?p=$2 [L]
RewriteRule ^/?([a-z0-9]+)_([0-9]+).html$ index.php?act=$1&id=$2 [L]
RewriteRule ^/?([a-z0-9]+)-([0-9]+).html$ index.php?act=$1&cid=$2 [L]
RewriteRule ^/?([a-z0-9]+)-([0-9]+)-([0-9]+).html$ index.php?act=$1&cid=$2&p=$3 [L]
httpd.ini示例:
[ISAPI_Rewrite]
RepeatLimit 32
# Block external access to the httpd.ini and httpd.parse.errors files
RewriteRule /httpd(?:.ini|.parse.errors).* / [F,I,O]
# Block external access to the Helper ISAPI Extension
RewriteRule .*.isrwhlp / [F,I,O]
RewriteRule ^/(index|guestbook|online).html$ /$1.php
RewriteRule ^/(eindex).html$ /index.php?act=$1
RewriteRule ^/(index|guestbook|online)-([0-9]+).html$ /$1.php?p=$2
RewriteRule ^/([a-z0-9]+)_([0-9]+).html$ /index.php?act=$1&id=$2
RewriteRule ^/([a-z0-9]+)-([0-9]+).html$ /index.php?act=$1&cid=$2
RewriteRule ^/([a-z0-9]+)-([0-9]+)-([0-9]+).html$ /index.php?act=$1&cid=$2&p=$3
最新回答共有2条回答
-
游客
回复首先 下载文件 dv_iis_url_rewrite zip 将其解压到本地硬盘(压缩包里有两个文件 分别是IisUrlRewriter dll和IisUrlRewriter ini) 然后打开IIS管理器
选择 ISAPI筛选器 然后选择 添加
在 添加/编辑筛选器属性 对话框中 点击 浏览
在这里 选择刚才解压出来的IisUrlRewriter dll
点击 确定 结束设置
如果设置没有生效 你需要重启IIS
如果需要在IIS里开启ASP帖子URL到PHP帖子的映射 你需要修改解压出来的IisUrlRewriter ini文件
lishixinzhi/Article/program/net/201311/11985