.htaccess 重定向页面速度问题

.htaccess 重定向页面速度问题,.htaccess,redirect,web,opencart,pagespeed,.htaccess,Redirect,Web,Opencart,Pagespeed,我曾尝试在所有运行良好的网站上强制使用WWW,但当我进行页面速度测试时,我得到了以下建议(例如): 这是我的htaccess: # 1.To use URL Alias you need to be running apache with mod_rewrite enabled. # 2. In your opencart directory rename htaccess.txt to .htaccess. # For any support issues please visit: h

我曾尝试在所有运行良好的网站上强制使用WWW,但当我进行页面速度测试时,我得到了以下建议(例如):

这是我的htaccess:

# 1.To use URL Alias you need to be running apache with mod_rewrite enabled. 

# 2. In your opencart directory rename htaccess.txt to .htaccess.

# For any support issues please visit: http://www.opencart.com

Options +FollowSymlinks

# Prevent Directoy listing 
Options -Indexes

# Prevent Direct Access to files
<FilesMatch "\.(tpl|ini|log)">
 Order deny,allow
 Deny from all
</FilesMatch>

# SEO URL Settings
RewriteEngine On
# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/ 

### Tomas Changes

#RewriteCond %{QUERY_STRING}  ^$
#RewriteRule ^product_id=30$ http://nerdtshirtsuk.com/index.php?route=checkout/cart [R=301,NE,NC,L]
#RewriteRule ^index.php?route=product/product&path=17&product_id=30$ /contact_us\.html [R=301,L]
#RewriteRule ^route=product/product&path=17&product_id=30$ http://swing-and-play.com/ [R=301,L]
#Redirect 301 /index.php?route=product/product&path=17&product_id=30 http://swing-and-play.com/
#RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
#RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
#RewriteCond %{HTTP_HOST} !^www\.
#RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
#RewriteCond %{http_host} ^swing-and-play.com [nc]
#RewriteRule ^(.*)$ http://www.swing-and-play.com/$1 [r=301,nc]


### Tomas Changes End


RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^download/(.*) /index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA] 

RewriteCond %{http_host} ^swing-and-play.com [nc]
RewriteRule ^(.*)$ http://www.swing-and-play.com/$1 [r=301,nc]




### Additional Settings that may need to be enabled for some servers 
### Uncomment the commands by removing the # sign in front of it.
### If you get an "Internal Server Error 500" after enabling any of the following settings, restore the # as this means your host doesn't allow that.

# 1. If your cart only allows you to add one item at a time, it is possible register_globals is on. This may work to disable it:
# php_flag register_globals off

# 2. If your cart has magic quotes enabled, This may work to disable it:
# php_flag magic_quotes_gpc Off

# 3. Set max upload file size. Most hosts will limit this and not allow it to be overridden but you can try
# php_value upload_max_filesize 999M

# 4. set max post size. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value post_max_size 999M

# 5. set max time script can take. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_execution_time 200

# 6. set max time for input to be recieved. Uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_input_time 200

# 7. disable open_basedir limitations
# php_admin_value open_basedir none

<IfModule mod_expires.c>

    ExpiresActive on
    ExpiresDefault "access plus 1 month"

  # CSS
    ExpiresByType text/css "access plus 1 year"

  # Data interchange
    ExpiresByType application/json "access plus 0 seconds"
    ExpiresByType application/ld+json "access plus 0 seconds"
    ExpiresByType application/xml "access plus 0 seconds"
    ExpiresByType text/xml "access plus 0 seconds"

  # Favicon (cannot be renamed!) and cursor images
    ExpiresByType image/x-icon "access plus 1 week"

  # HTML components (HTCs)
    ExpiresByType text/x-component "access plus 1 month"

  # HTML
    ExpiresByType text/html "access plus 0 seconds"

  # JavaScript
    ExpiresByType application/javascript "access plus 1 year"

  # Manifest files
    ExpiresByType application/x-web-app-manifest+json "access plus 0 seconds"
    ExpiresByType text/cache-manifest "access plus 0 seconds"

  # Media
    ExpiresByType audio/ogg "access plus 1 month"
    ExpiresByType image/gif "access plus 1 month"
    ExpiresByType image/jpeg "access plus 1 month"
    ExpiresByType image/png "access plus 1 month"
    ExpiresByType video/mp4 "access plus 1 month"
    ExpiresByType video/ogg "access plus 1 month"
    ExpiresByType video/webm "access plus 1 month"

  # Web feeds
    ExpiresByType application/atom+xml "access plus 1 hour"
    ExpiresByType application/rss+xml "access plus 1 hour"

  # Web fonts
    ExpiresByType application/font-woff "access plus 1 month"
    ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
    ExpiresByType application/x-font-ttf "access plus 1 month"
    ExpiresByType font/opentype "access plus 1 month"
    ExpiresByType image/svg+xml "access plus 1 month"

</IfModule>

# compress text, HTML, JavaScript, CSS, and XML
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

# remove browser bugs
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent
#1.要使用URL别名,您需要在启用mod#u rewrite的情况下运行apache。
# 2. 在opencart目录中,将htaccess.txt重命名为.htaccess。
#有关任何支持问题,请访问:http://www.opencart.com
选项+FollowSymlinks
#防止Directoy上市
选项-索引
#阻止直接访问文件
命令拒绝,允许
全盘否定
#搜索引擎优化URL设置
重新启动发动机
#如果您的opencart安装没有在主web文件夹上运行,请确保您的文件夹在ie中运行。/been/shop/
###托马斯的变化
#重写cond%{QUERY_STRING}^$
#重写规则^product\U id=30美元http://nerdtshirtsuk.com/index.php?route=checkout/cart [R=301,东北,北卡罗来纳,北卡罗来纳]
#重写规则^index.php?route=product/product&path=17&product\u id=30$/contact\u us\.html[R=301,L]
#重写规则^route=product/product&path=17&product\u id=30美元http://swing-and-play.com/ [R=301,L]
#重定向301/index.php?route=product/product&path=17&product\u id=30http://swing-and-play.com/
#重写cond%{HTTP_HOST}^www\.(.*)$[NC]
#重写规则^(.*)$http://www.%{HTTP_HOST}/$1[R=301,L]
#重写cond%{HTTP_HOST}^www\。
#重写规则^(.*)$http://www.%{HTTP_HOST}/$1[R=301,L]
#重写cond%{http_host}^swing-and-play.com[nc]
#重写规则^(.*)$http://www.swing-and-play.com/$1[r=301,北卡罗来纳州]
###托马斯的变化结束了
重写基/
重写规则^sitemap.xml$index.php?route=feed/google_sitemap[L]
重写规则^googlebase.xml$index.php?route=feed/google_base[L]
重写规则^download/(.*)/index.php?route=error/not_found[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写条件%{REQUEST\u URI}!。*\。(ico | gif | jpg | jpeg | png | js | css)
RewriteRule^([^?]*)index.php?_route_uu=$1[L,QSA]
重写cond%{http_host}^swing-and-play.com[nc]
重写规则^(.*)$http://www.swing-and-play.com/$1[r=301,北卡罗来纳州]
###某些服务器可能需要启用的其他设置
###通过删除前面的#符号来取消对命令的注释。
###如果在启用以下任何设置后出现“内部服务器错误500”,请恢复#,因为这意味着您的主机不允许这样做。
# 1. 如果您的购物车一次只允许您添加一个项目,则可以启用register_globals。这可能会禁用它:
#php_标志寄存器_全局关闭
# 2. 如果您的购物车启用了魔法报价,这可能会使其禁用:
#php_标志魔术_引号_gpc关闭
# 3. 设置最大上载文件大小。大多数主机将对此进行限制,并且不允许覆盖它,但您可以尝试
#php_值上传_最大_文件大小999M
# 4. 设置最大邮件大小。如果有很多产品选项或表单未保存所有字段时出现错误,请取消对此行的注释
#php_值post_最大尺寸999M
# 5. 设置脚本可以花费的最大时间。如果有很多产品选项或表单未保存所有字段时出现错误,请取消对此行的注释
#php_值最大执行时间200
# 6. 设置接收输入的最长时间。如果有很多产品选项或表单未保存所有字段时出现错误,请取消对此行的注释
#php_值最大输入时间200
# 7. 禁用open_basedir限制
#php\u admin\u值open\u basedir无
过期于
ExpiresDefault“访问加1个月”
#CSS
ExpiresByType文本/css“访问加1年”
#数据交换
ExpiresByType应用程序/json“访问加0秒”
ExpiresByType应用程序/ld+json“访问加0秒”
ExpiresByType应用程序/xml“访问加0秒”
ExpiresByType text/xml“访问加0秒”
#Favicon(无法重命名!)和光标图像
ExpiresByType图像/x图标“访问加1周”
#HTML组件(HTC)
ExpiresByType文本/x组件“访问加1个月”
#HTML
ExpiresByType text/html“访问加0秒”
#JavaScript
ExpiresByType应用程序/javascript“访问加1年”
#清单文件
ExpiresByType应用程序/x-web-app-manifest+json“访问加0秒”
ExpiresByType文本/缓存清单“访问加0秒”
#媒体
ExpiresByType音频/ogg“访问加1个月”
ExpiresByType image/gif“访问加1个月”
过期按类型图像/jpeg“访问加1个月”
ExpiresByType图像/png“访问加1个月”
按类型视频/mp4“访问加1个月”过期
按类型视频/ogg“访问加1个月”过期
过期按类型视频/webm“访问加1个月”
#网络源
ExpiresByType应用程序/atom+xml“访问加1小时”
ExpiresByType应用程序/rss+xml“访问加1小时”
#网页字体
过期按类型应用程序/font woff“访问加1个月”
ExpiresByType应用程序/vnd.ms-fontobject“访问加1个月”
按类型应用程序到期/x-font-ttf“访问加1个月”
ExpiresByType字体/opentype“访问加1个月”
ExpiresByType图像/svg+xml“访问加1个月”
#压缩文本、HTML、JavaScript、CSS和XML
AddOutputFilterByType泄气文本/普通
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE应用程序/xml
AddOutputFilterByType DEFLATE应用程序/xhtml+xml
AddOutputFilterByType DEFLATE应用程序/rss+xml
AddOutputFilterByType DEFLATE应用程序/javascript
AddOutputFilterByType DEFLATE应用程序/x-javascript
#删除浏览器错误
浏览器匹配^Mozilla/4 gzip纯文本/html
浏览器匹配^Mozilla/4\.0[678]无gzip
BrowserMatch\bMSIE!没有gzip!仅限gzip文本/html
头附加用户代理

您能帮我找出这里的错误吗?

该错误表示您正在链接到没有www的图像,因此请求被重定向

在HTML中查找指向
http://swing-and-play.com/catalog/view/theme/shopzone/image/social/facebook500.png
并修复它

# 1.To use URL Alias you need to be running apache with mod_rewrite enabled. 

# 2. In your opencart directory rename htaccess.txt to .htaccess.

# For any support issues please visit: http://www.opencart.com

Options +FollowSymlinks

# Prevent Directoy listing 
Options -Indexes

# Prevent Direct Access to files
<FilesMatch "\.(tpl|ini|log)">
 Order deny,allow
 Deny from all
</FilesMatch>

# SEO URL Settings
RewriteEngine On
# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/ 

### Tomas Changes

#RewriteCond %{QUERY_STRING}  ^$
#RewriteRule ^product_id=30$ http://nerdtshirtsuk.com/index.php?route=checkout/cart [R=301,NE,NC,L]
#RewriteRule ^index.php?route=product/product&path=17&product_id=30$ /contact_us\.html [R=301,L]
#RewriteRule ^route=product/product&path=17&product_id=30$ http://swing-and-play.com/ [R=301,L]
#Redirect 301 /index.php?route=product/product&path=17&product_id=30 http://swing-and-play.com/
#RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
#RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
#RewriteCond %{HTTP_HOST} !^www\.
#RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
#RewriteCond %{http_host} ^swing-and-play.com [nc]
#RewriteRule ^(.*)$ http://www.swing-and-play.com/$1 [r=301,nc]


### Tomas Changes End


RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^download/(.*) /index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA] 

RewriteCond %{http_host} ^swing-and-play.com [nc]
RewriteRule ^(.*)$ http://www.swing-and-play.com/$1 [r=301,nc]




### Additional Settings that may need to be enabled for some servers 
### Uncomment the commands by removing the # sign in front of it.
### If you get an "Internal Server Error 500" after enabling any of the following settings, restore the # as this means your host doesn't allow that.

# 1. If your cart only allows you to add one item at a time, it is possible register_globals is on. This may work to disable it:
# php_flag register_globals off

# 2. If your cart has magic quotes enabled, This may work to disable it:
# php_flag magic_quotes_gpc Off

# 3. Set max upload file size. Most hosts will limit this and not allow it to be overridden but you can try
# php_value upload_max_filesize 999M

# 4. set max post size. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value post_max_size 999M

# 5. set max time script can take. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_execution_time 200

# 6. set max time for input to be recieved. Uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_input_time 200

# 7. disable open_basedir limitations
# php_admin_value open_basedir none

<IfModule mod_expires.c>

    ExpiresActive on
    ExpiresDefault "access plus 1 month"

  # CSS
    ExpiresByType text/css "access plus 1 year"

  # Data interchange
    ExpiresByType application/json "access plus 0 seconds"
    ExpiresByType application/ld+json "access plus 0 seconds"
    ExpiresByType application/xml "access plus 0 seconds"
    ExpiresByType text/xml "access plus 0 seconds"

  # Favicon (cannot be renamed!) and cursor images
    ExpiresByType image/x-icon "access plus 1 week"

  # HTML components (HTCs)
    ExpiresByType text/x-component "access plus 1 month"

  # HTML
    ExpiresByType text/html "access plus 0 seconds"

  # JavaScript
    ExpiresByType application/javascript "access plus 1 year"

  # Manifest files
    ExpiresByType application/x-web-app-manifest+json "access plus 0 seconds"
    ExpiresByType text/cache-manifest "access plus 0 seconds"

  # Media
    ExpiresByType audio/ogg "access plus 1 month"
    ExpiresByType image/gif "access plus 1 month"
    ExpiresByType image/jpeg "access plus 1 month"
    ExpiresByType image/png "access plus 1 month"
    ExpiresByType video/mp4 "access plus 1 month"
    ExpiresByType video/ogg "access plus 1 month"
    ExpiresByType video/webm "access plus 1 month"

  # Web feeds
    ExpiresByType application/atom+xml "access plus 1 hour"
    ExpiresByType application/rss+xml "access plus 1 hour"

  # Web fonts
    ExpiresByType application/font-woff "access plus 1 month"
    ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
    ExpiresByType application/x-font-ttf "access plus 1 month"
    ExpiresByType font/opentype "access plus 1 month"
    ExpiresByType image/svg+xml "access plus 1 month"

</IfModule>

# compress text, HTML, JavaScript, CSS, and XML
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

# remove browser bugs
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent