php僞靜态後html不能通路如何解決
釋出時間:2020-09-22 10:05:38
來源:億速雲
閱讀:65
作者:小新
php僞靜态後html不能通路如何解決?這個問題可能是我們日常學習或工作經常見到的。希望通過這個問題能讓你收獲頗深。下面是小編給大家帶來的參考内容,讓我們一起來看看吧!php僞靜态後html不能通路的解決辦法:首先判斷檔案是否存在;然後設定存在則不rewirte,不存在且符合規則才rewrite;最後修改htaccess檔案即可。
![](https://img.laitimes.com/img/__Qf2AjLwojIjJCLyojI0JCLicmbw5yYilDN4UzM4QGN5QTZ5EWZwEGMldTMycTM5UjYjBjZz8CX0JXZ252bj91Ztl2Lc52YucWbp5GZzNmLn9Gbi1yZtl2Lc9CX6MHc0RHaiojIsJye.png)
具體問題:
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]
感謝各位的閱讀!看完上述内容,你們對php僞靜态後html不能通路如何解決大概了解了嗎?希望文章内容對大家有所幫助。如果想了解更多相關文章内容,歡迎關注億速雲行業資訊頻道。