【亿码酷站-编程开发教程】收集全网优质教程及源码资源!

全网优质软件开发、平面设计等教程及精品源码资源一站可得,www.ymkuzhan.com!

php伪静态后html不能访问怎么办_亿码酷站_编程开发技术教程插图

推荐:《PHP视频教程

具体问题:

PHP伪静态后不能访问纯html文件

.htaccess文件

RewriteEngine on
RewriteRule index.html$ index.php
RewriteRule art.html$ project.php?file=art
RewriteRule music.html$ project.php?file=music
RewriteRule dance.html$ project.php?file=dance
RewriteRule radio.html$ project.php?file=radio
RewriteRule director.html$ project.php?file=director
RewriteRule perform.html$ project.php?file=perform
RewriteRule flight.html$ project.php?file=flight
RewriteRule ([a-zA-Z]+)-([0-9]+).html$ page.php?pageid=$2
RewriteRule ([a-zA-Z]+)-([0-9]+)-([0-9]+).html$ page.php?pageid=$2&info=$3
RewriteRule ([a-zA-Z]+)-([0-9]+)-rules-(.*)-([a-zA-Z]+).html$ page.php?pageid=$2&info=$3&file=$4
RewriteRule ([a-zA-Z]+)-([0-9]+)-([0-9]+)-([a-zA-Z]+).html$ page.php?pageid=$2&menuid=$3&file=$4
RewriteRule ([a-zA-Z]+)-([0-9]+)-([a-zA-Z]+).html$ page.php?pageid=$2&file=$3
RewriteRule ([a-zA-Z]+)-([0-9]+)-([a-zA-Z]+)-list([0-9]+).html$ page.php?pageid=$2&file=$3&page=$4
RewriteRule ([a-zA-Z]+)-([0-9]+)-([0-9]+)-([a-zA-Z]+)-list([0-9]+).html$ page.php?pageid=$2&menuid=$3&file=$4&page=$5
RewriteRule ([a-zA-Z]+)-([0-9]+)-([0-9]+)-(.*)-([a-zA-Z]+).html$ page.php?pageid=$2&menuid=$3&artid=$4&file=$5

而且我都已经把 RewriteRule index.html$ index.php 这句去掉了 但打开的时候 还是反问伪静态

我现在要访问网站里的纯静态HTML文件,同时又要求PHP的伪静态也能访问,怎么做?

解决办法:

应该先判断文件是否存在,存在则不rewirte。不存在且符合规则才rewrite

例如:文件或目录不存在则rewrite到index.php,否则直接读取存在的文件。

<IfModule rewrite_module>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/\ [QSA,PT,L]
</IfModule>

php伪静态后html不能访问怎么办
—–文章转载自PHP中文网如有侵权请联系admin#tyuanma.cn删除

php下载文件无法打开怎么办

云服务器推荐