删除双斜杠 - 打开购物车

Remove Double trailing slash - open cart

我一直在不断升级我的 htaccess 文件。但是,有 2 个问题我似乎无法解决。我尝试了几种方法,但对我来说没有任何效果。

  1. 我的网站:https://www.zeroohm.com/
  2. 我的问题:

    • 如何在转到 zeroohm.com 时删除多余的尾部斜杠 目前,如果我转到 zeroohm.com,它会重定向到 https://www.zeroohm.com//

    • 如果我转到 www.zeroohm.com/robots.txt/ ,它会阻止我查看我的 robots.txt 文件(处理此指令时发生错误) .我怎样才能解决这个问题?这个问题发生在 sitemap.xml 上,它也会导致网站管理员工具出现问题。 C. 有什么改进我的重定向的想法吗?

  3. 我的 htaccess 文件

RewriteEngine On

RewriteCond %{HTTP_HOST} ^zeroohm\.ae$ [OR]
RewriteCond %{HTTP_HOST} ^www\.zeroohm\.ae$
RewriteRule ^/?$ "http\:\/\/www\.zeroohm\.com\/$1\/" [R=301,L]


# check if url has www or not, add www if not available. if avaiable dont do anything.
RewriteCond %{HTTP_HOST} !^$ 
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*) https://www.%{HTTP_HOST}%{REQUEST_URI}/ [R=301,L]
#end

# force incoming traffic coming from HTTP to Https 
RewriteCond %{HTTPS} !on$
RewriteRule ^(.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
#end


#force trainling slash 

RewriteBase /
RewriteCond %{REQUEST_URI} !(/$|\.) 
RewriteCond %{REQUEST_URI} /+[^\.]+$
RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]
#end of force trailing slash




# 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
# For security reasons, Option followsymlinks cannot be overridden.
#Options +FollowSymlinks

Options +SymLinksIfOwnerMatch
# Prevent Directoy listing 
Options -Indexes

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


# cache to keep it at client pc
<ifmodule mod_expires.c>
    Expiresactive on
    # set default
    Expiresdefault "access plus 24 hours"
    Expiresbytype image/jpg "access plus 1 months"
    Expiresbytype image/gif "access plus 1 months"
    Expiresbytype image/jpeg "access plus 1 months"
    Expiresbytype image/png "access plus 1 months"
    Expiresbytype text/css "access plus 1 months"
    Expiresbytype text/javascript "access plus 1 months"
    Expiresbytype application/javascript "access plus 1 months"
    Expiresbytype application/x-shockwave-flash "access plus 1 months"
</ifmodule>

#gzip compression
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


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




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_= [L,QSA]

#libwww-perl security fix
RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule .* ? [F,L]


RewriteCond %{THE_REQUEST} \ /index\.php\?_route_=?([^&\ ]*)
RewriteRule ^ /%1? [R=301,L]

您可以将这些规则保存在站点根目录 .htaccess 中:

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^(?:www\.)?zeroohm\.ae$ [NC]
RewriteRule ^ http://www.zeroohm.com%{REQUEST_URI} [R=301,L,NE]

# check if url has www or not, add www if not available. if avaiable don't do anything.
RewriteCond %{HTTP_HOST} !^www\. [NC,OR]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [R=301,L,NE]

#force trailing slash     
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(/$|\.) 
RewriteCond %{REQUEST_URI} /+[^\.]+$
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]

#libwww-perl security fix
RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule ^ - [F,L]

RewriteCond %{THE_REQUEST} \ /index\.php\?_route_=?([^&\s]*)
RewriteRule ^ /%1? [R=301,L]

RewriteRule ^sitemap\.xml$ index.php?route=feed/google_sitemap [L,QSA,NC]

RewriteRule ^googlebase\.xml$ index.php?route=feed/google_base [L,QSA,NC]

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_=[=10=] [L,QSA]

在测试此更改之前清除您的浏览器缓存。