Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php &引用;肮脏的”。htaccess文件?_Php_Wordpress_Apache_.htaccess - Fatal编程技术网

Php &引用;肮脏的”。htaccess文件?

Php &引用;肮脏的”。htaccess文件?,php,wordpress,apache,.htaccess,Php,Wordpress,Apache,.htaccess,注意-我是一个相当缺乏经验的技术人员,但肯定比我的同伴更技术!我们有一个WordPress网站,并且已经安装/删除了各种插件 写这篇文章的原因是我们的网站上出现了严重的等待/TTFB问题。该站点托管在Apache VPS上,我了解到.htaccess文件对于此类设置可能有问题 如有任何建议/指导,将不胜感激!我们只是想检查一下.htaccess文件是否看起来“正常”?对于未经培训的人来说,它看起来像是底部有一些重复,还有一个语句“AddType x-httpd-php54.php”——我想确保在

注意-我是一个相当缺乏经验的技术人员,但肯定比我的同伴更技术!我们有一个WordPress网站,并且已经安装/删除了各种插件

写这篇文章的原因是我们的网站上出现了严重的等待/TTFB问题。该站点托管在Apache VPS上,我了解到.htaccess文件对于此类设置可能有问题

如有任何建议/指导,将不胜感激!我们只是想检查一下.htaccess文件是否看起来“正常”?对于未经培训的人来说,它看起来像是底部有一些重复,还有一个语句“AddType x-httpd-php54.php”——我想确保在这个级别上是必要的。.htaccess文件存储在public_html文件夹中

# BEGIN WpFastestCache
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(.*)$ http\:\/\/example\.com\/$1 [R=301,L]
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} !(\/){2}$
RewriteCond %{QUERY_STRING} !.+
RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress_logged_in|wp_woocommerce_session).*$
RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\"]+ [NC]
RewriteCond %{HTTP:Profile} !^[a-z0-9\"]+ [NC]
RewriteCond %{HTTP_USER_AGENT} !^.*(iphone|midp|sony|symbos|nokia|samsung|mobile|epoc|ericsson|panasonic|philips|sanyo|sharp|sie-|portalmmm|blazer|avantgo|danger|palm|series60|palmsource|pocketpc|android|blackberry|playbook|ipad|ipod|iemobile|palmos|webos|googlebot-mobile|bb10|xoom|p160u|nexus|touch|SCH-I800|opera\smini|SM-G900R4|LG-|HTC|GT-I9505|WAP-Browser|Nokia309|Casper_VIA).*$ [NC]
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/all/$1/index.html -f [or]
RewriteCond /var/sites/b/example.com/public_html/wp-content/cache/all/$1/index.html -f
RewriteRule ^(.*) "/wp-content/cache/all/$1/index.html" [L]
</IfModule>
<FilesMatch "\.(html|htm)$">
AddDefaultCharset UTF-8
<ifModule mod_headers.c>
FileETag None
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Mon, 29 Oct 1923 20:30:00 GMT"
</ifModule>
</FilesMatch>
# END WpFastestCache
# BEGIN GzipWpFastestCache
<IfModule mod_deflate.c>
AddType x-font/woff .woff
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE font/opentype font/ttf font/eot font/otf
</IfModule>
# END GzipWpFastestCache
# BEGIN LBCWpFastestCache
<FilesMatch "\.(?i:ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf|x-html|css|xml|js|woff|woff2|ttf|svg|eot)(\.gz)?$">
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault A0
ExpiresByType image/gif A2592000
ExpiresByType image/png A2592000
ExpiresByType image/jpg A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType image/ico A2592000
ExpiresByType image/svg+xml A2592000
ExpiresByType text/css A2592000
ExpiresByType text/javascript A2592000
ExpiresByType application/javascript A2592000
</IfModule>
<IfModule mod_headers.c>
Header set Expires "max-age=2592000, public"
Header unset ETag
Header set Connection keep-alive
FileETag None
</IfModule>
</FilesMatch>
# END LBCWpFastestCache
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
#Gzip AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript text/javascript #End Gzip
AddType x-httpd-php54 .php
#开始WpFastestCache
重新启动发动机
重写基/
重写cond%{HTTP_HOST}^www.example.com[NC]
重写规则^(.*)$http\:\/\/example\.com\/$1[R=301,L]
重写cond%{REQUEST_METHOD}!邮递
重写cond%{HTTPS}=在…上
重写cond%{REQUEST_URI}!(\/){2}$
重写条件%{QUERY_STRING}+
重写cond%{HTTP:Cookie}!^*(评论:作者:wordpress:登录:wp:商业会议)*$
重写cond%{HTTP:X-Wap-Profile}^[a-z0-9\“]+[NC]
重写cond%{HTTP:Profile}!^[a-z0-9\“]+[NC]
重写cond%{HTTP\u USER\u AGENT}!^*“iphone(iphone)和中期P(244)的方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方方124; p160u | nexus | touch | SCH-I800 | opera\smini | SM-G900R4 | LG | HTC | GT-I9505 | WAP浏览器|诺基亚309 |卡斯珀| VIA).*$[NC]
RewriteCond%{DOCUMENT_ROOT}/wp content/cache/all/$1/index.html-f[或]
重写cond/var/sites/b/example.com/public_html/wp content/cache/all/$1/index.html-f
重写规则^(.*)“/wp content/cache/all/$1/index.html”[L]
AddDefaultCharset UTF-8
FileTag无
标题未设置ETag
标题集缓存控制“最大年龄=0,无缓存,无存储,必须重新验证”
标题集Pragma“无缓存”
标题集过期“1923年10月29日星期一20:30:00 GMT”
#结束WPFastTestCache
#开始GZIPWPFastTestCache
AddType x-font/woff.woff
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType泄气文本/普通
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE应用程序/xml
AddOutputFilterByType DEFLATE应用程序/xhtml+xml
AddOutputFilterByType DEFLATE应用程序/rss+xml
AddOutputFilterByType DEFLATE应用程序/javascript
AddOutputFilterByType DEFLATE应用程序/x-javascript
AddOutputFilterByType放气应用程序/x-font-ttf
AddOutputFilterByType DEFLATE应用程序/vnd.ms-fontobject
AddOutputFilterByType DEFLATE字体/opentype字体/ttf字体/eot字体/otf
#结束GZIPWPFastTestCache
#开始LBCWpFastestCache
过期于
到期默认A0
ExpiresByType图像/gif A2592000
ExpiresByType图像/png A2592000
ExpiresByType图像/jpg A2592000
过期按类型图像/jpeg A2592000
ExpiresByType图像/ico A2592000
ExpiresByType图像/svg+xml A2592000
ExpiresByType文本/css A2592000
ExpiresByType文本/javascript A2592000
ExpiresByType应用程序/javascript A2592000
标题集过期“最大年龄=2592000,公共”
标题未设置ETag
标题集连接保持活动状态
FileTag无
#结束LBCWpFastestCache
#开始WordPress
重新启动发动机
重写基/
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
#结束WordPress
#开始WordPress
重新启动发动机
重写基/
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
#结束WordPress
#Gzip AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript text/javascript#End Gzip
AddType x-httpd-php54.php

.htaccess
文件没有问题。除了在结尾重复Wordpress Dispatcher:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
#开始WordPress
重新启动发动机
重写基/
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
#结束WordPress
#开始WordPress
重新启动发动机
重写基/
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
#结束WordPress
你可以移除其中一个。但这不会改变Apache的性能。第一条规则是第一条,第二条规则永远达不到

其他规则仅设置缓存管理、缓存过期标头和压缩


关于
AddType x-httpd-php54.php
,您正在设置网站使用的
php
版本。您可以尝试使用更高版本(如果主机可用),并查看是否存在兼容性错误。

从Apache移动到NGINX将是一个永久解决方案。您完全可以删除重复的
\BEGIN WordPress…\END WordPress
部分。
x-httpd-php54
用于选择PHP5.4(假设您有多个可用版本)。如果您的服务器上的版本高于5.4,您应该改用它-如果它是默认版本,您可以删除该行。由于“off-topic”标志,您投了反对票。mods的公平点和这类问题通常会随着时间的推移而得票。干杯,克劳伊特谢谢你弗洛里安,我已经删除了Wordpress调度员的重复。现在,创建一张罚单,尝试一劳永逸地解决我的性能问题!