php伪静态后html不能访问的解决办法:首先判断文件是否存在;然后设置存在则不rewirte,不存在且符合规则才rewrite;最后修改htaccess文件即可。
具体问题:
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,否则直接读取存在的文件。
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]