2014-10-02 118 views
1

我有一个网站“www.example.net”HTTP 301重定向性能

但我注意到,当我进入“example.net”(到浏览器),我会先收到一个301,这将正确重定向到网站。

我的问题是它需要6 - 17秒才会被重定向。

我想知道的是,如此广泛的操作以及如何解决这个问题的原因是什么?

其他信息 网站是一个Apache服务器上的Wordpress网站。

编辑 的.htaccess

# BEGIN W3TC Browser Cache 
<IfModule mod_deflate.c> 
    <IfModule mod_headers.c> 
     Header append Vary User-Agent env=!dont-vary 
    </IfModule> 
     AddOutputFilterByType DEFLATE text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/json 
    <IfModule mod_mime.c> 
     # DEFLATE by extension 
     AddOutputFilter DEFLATE js css htm html xml 
    </IfModule> 
</IfModule> 
<FilesMatch "\.(css|htc|less|js|js2|js3|js4|CSS|HTC|LESS|JS|JS2|JS3|JS4)$"> 
    FileETag MTime Size 
    <IfModule mod_headers.c> 
     Header set Pragma "public" 
     Header set Cache-Control "max-age=31536000, public" 
     Header set X-Powered-By "W3 Total Cache/0.9.4" 
    </IfModule> 
</FilesMatch> 
<FilesMatch "\.(html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml|HTML|HTM|RTF|RTX|SVG|SVGZ|TXT|XSD|XSL|XML)$"> 
    FileETag MTime Size 
    <IfModule mod_headers.c> 
     Header set Pragma "public" 
     Header set Cache-Control "max-age=3600, public" 
     Header set X-Powered-By "W3 Total Cache/0.9.4" 
    </IfModule> 
</FilesMatch> 
<FilesMatch "\.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|json|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|woff|xla|xls|xlsx|xlt|xlw|zip|ASF|ASX|WAX|WMV|WMX|AVI|BMP|CLASS|DIVX|DOC|DOCX|EOT|EXE|GIF|GZ|GZIP|ICO|JPG|JPEG|JPE|JSON|MDB|MID|MIDI|MOV|QT|MP3|M4A|MP4|M4V|MPEG|MPG|MPE|MPP|OTF|ODB|ODC|ODF|ODG|ODP|ODS|ODT|OGG|PDF|PNG|POT|PPS|PPT|PPTX|RA|RAM|SVG|SVGZ|SWF|TAR|TIF|TIFF|TTF|TTC|WAV|WMA|WRI|WOFF|XLA|XLS|XLSX|XLT|XLW|ZIP)$"> 
    FileETag MTime Size 
    <IfModule mod_headers.c> 
     Header set Pragma "public" 
     Header set Cache-Control "max-age=31536000, public" 
     Header set X-Powered-By "W3 Total Cache/0.9.4" 
    </IfModule> 
</FilesMatch> 
# END W3TC Browser Cache 
# BEGIN W3TC CDN 
<FilesMatch "\.(ttf|ttc|otf|eot|woff|font.css)$"> 
<IfModule mod_headers.c> 
    Header set Access-Control-Allow-Origin "*" 
</IfModule> 
</FilesMatch> 
# END W3TC CDN 
# BEGIN W3TC Page Cache core 
<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase/
    RewriteCond %{HTTP:Accept-Encoding} gzip 
    RewriteRule .* - [E=W3TC_ENC:_gzip] 
    RewriteCond %{HTTP_COOKIE} w3tc_preview [NC] 
    RewriteRule .* - [E=W3TC_PREVIEW:_preview] 
    RewriteCond %{REQUEST_METHOD} !=POST 
    RewriteCond %{QUERY_STRING} ="" 
    RewriteCond %{REQUEST_URI} \/$ 
    RewriteCond %{HTTP_COOKIE} !(comment_author|wp\-postpass|w3tc_logged_out|wordpress_logged_in|wptouch_switch_toggle) [NC] 
    RewriteCond "%{DOCUMENT_ROOT}/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" -f 
    RewriteRule .* "/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" [L] 
</IfModule> 
# END W3TC Page Cache core 
# 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 
+0

应该以毫秒为单位发生。你的htaccess规则内容是什么? – briansol 2014-10-02 18:50:39

+0

你的意思是什么在我的htaccess文件? – PrivatMamtora 2014-10-02 19:08:42

+0

这谷歌结果似乎相关:https://wordpress.org/support/topic/painfully-slow-301-redirect-from-htaccess-trailing-slash – xpa1492 2014-10-03 04:07:07

回答

0

您有非www重定向到www没有htaccess的规则。如果它正在重定向,那是因为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> 

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase/
    RewriteCond %{HTTP_HOST} ^yourdomain.com [NC] 
    RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301] 
    RewriteRule ^index\.php$ - [L] 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule . /index.php [L] 
</IfModule>