PHP가 의사 정적(pseudo-static)인 후에 html에 액세스할 수 없으면 어떻게 해야 합니까?

PHPz
풀어 주다: 2023-03-05 21:52:01
원래의
3005명이 탐색했습니다.

php伪静态后html不能访问的解决办法:首先判断文件是否存在;然后设置存在则不rewirte,不存在且符合规则才rewrite;最后修改htaccess文件即可。

PHP가 의사 정적(pseudo-static)인 후에 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/$1 [QSA,PT,L]
</IfModule>
로그인 후 복사

위 내용은 PHP가 의사 정적(pseudo-static)인 후에 html에 액세스할 수 없으면 어떻게 해야 합니까?의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

관련 라벨:
php
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!