【发布时间】:2021-01-21 15:43:57
【问题描述】:
我是编码新手,如果有简单的解决方案,请见谅。
我刚刚尝试使用 FTP 传输一个全新的网站以替换旧版本,但是当尝试加载 index.php 页面时,它会下载该页面而不是加载它。我需要在我的 .htaccess 文件中添加什么来阻止这种情况发生吗?还是我错过了其他元素?
这是我当前的 .htaccess 文件;
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/opentype
# For Olders Browsers Which Can't Handle Compression
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>
#One year for image files
<filesMatch ".(jpg|jpeg|png|gif|ico|webp)$">
Header set Cache-Control "max-age=31536000, public"
</filesMatch>
#One month for css and js
<filesMatch ".(css|js|woff2)$">
Header set Cache-Control "max-age=31536000, public"
</filesMatch>
<IfModule mod_setenvif.c>
#Vary: Accept for all the requests to jpeg and png
SetEnvIf Request_URI "\.(jpe?g|png)$" REQUEST_image
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
# Check if browser supports WebP images
RewriteCond %{HTTP_ACCEPT} image/webp
# Check if WebP replacement image exists
RewriteCond %{DOCUMENT_ROOT}/$1.webp -f
# Serve WebP image instead
RewriteRule (.+)\.(jpe?g|png)$ $1.webp [T=image/webp]
</IfModule>
<IfModule mod_headers.c>
Header append Vary Accept env=REQUEST_image
</IfModule>
<IfModule mod_mime.c>
AddType image/webp .webp
</IfModule>
RewriteEngine On
RewriteBase /
# Force SSL
RewriteCond %{SERVER_PORT} ^80$
RewriteRule (.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
ErrorDocument 404 /index.php
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php56” package as the default “PHP” programming language.
<IfModule mime_module>
AddHandler application/x-httpd-ea-php56 .php .php5 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
【问题讨论】:
-
AddHandler application/x-httpd-ea-php56 .php .php5 .phtml— 危险 PHP 5.6 has been End Of Life for over a year。它没有得到安全修复。不要使用它。 (如果您遇到的问题是由未安装 PHP 5.6 的服务器引起的,我不会感到惊讶)。 -
刚刚检查了我的 cpanel 似乎我有一个新的 php 正在运行。如果我的服务器运行的是 7.0.33,我会将其更改为什么?
-
“它下载页面而不是加载它”实际上是什么意思?是下载的
index.php文件中的代码还是里面的代码解释的结果? -
页面是白色的,只是在下载index.php源代码。我已经通过 FTP 单独传输了文件,现在似乎可以正常工作了,这很奇怪