在將我的 php 版本從 5.6 升級到 7.4 并修改我的 .htaccess 檔案以確認新版本后,我的 html 頁面未處理其 php 代碼。換句話說,輸出的是 php 代碼本身,而不是其預期的計算。在版本升級之前,所有 php 代碼都運行良好。
在修改后的 .htaccess 檔案中,版本 7 替換了 AddHandlers 中的版本 5。使用 phpinfo 我檢查了 php 版本是否正確。這是正確的。
我知道我頁面上的代碼是正確的,因為當該頁面使用 .php 擴展名而不是 .html 擴展名時,它會正常運行。在版本升級之前它運行良好。我修改后的 .htaccess 有什么問題?首先,這是我修改后的 .htaccess 檔案:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://example.com/$1 [R,L]
RewriteOptions inherit
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php74” package as the default “PHP” programming language.
<IfModule mime_module>
AddHandler application/x-httpd-ea-php74 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
RewriteEngine on
<Files index.html>
AddHandler application/x-httpd-php7 .html
</Files>
<Files index2.html>
AddHandler application/x-httpd-php7 .html
</Files>
<Files index-threejs.html>
AddHandler application/x-httpd-php7 .html
</Files>
...這是我的舊 .htaccess 檔案,在 php 升級之前運行良好:
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#RewriteEngine On
#RewriteCond %{HTTP_HOST} dentonrainfall\.com [NC]
#RewriteCond %{SERVER_PORT} 80
#RewriteRule ^(.*)$ https://dentonrainfall.com/$1 [R,L]
RewriteEngine on
<Files index.html>
AddHandler application/x-httpd-php5 .html
</Files>
<Files index2.html>
AddHandler application/x-httpd-php5 .html
</Files>
<Files index-threejs.html>
AddHandler application/x-httpd-php5 .html
</Files>
RewriteEngine Off
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://dentonrainfall.com/$1 [R,L]
uj5u.com熱心網友回復:
Jan 的建議是解決方案。重復他們所說的話:
我注意到您的自定義 AddHandler 陳述句使用的 MIME 型別與顯然由 cPanel 自動生成的 MIME 型別不同,您是否嘗試過使用 application/x-httpd-ea-php74
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/425164.html
上一篇:.htaccess用變數重寫子域
