我有一个OpenCart多线程安装,这就是为什么我有几个域指向同一个服务器文件夹。在这个文件夹中,我有一个.htaccess
文件,我只能为其中一个域工作(在这种情况下:city-gardener.com
)。
以下是代码:
# Prevent Directoy listing
Options -Indexes
# Prevent Direct Access to files
<FilesMatch "\.(tpl|ini|log)">
Order deny,allow
Deny from all
</FilesMatch>
RewriteEngine On
RewriteBase /
# append WWW
RewriteCond %{HTTP_HOST} !^www.
RewriteCond %{HTTP_HOST} !^$ [NC]
RewriteRule ^(.*) https://www.%{HTTP_HOST}/$1 [R,L=301]
# delete trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} (.*)$
RewriteRule ^(.+)/$ https://www.city-gardener.com/$1 [R,L=301]
# Force SSL
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://www.city-gardener.com/$1 [R,L=301]
RewriteCond %{HTTPS} !=off
# SEO URL Settings
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [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]
RewriteRule ^(?:(?:(\w{2})(?:/|\z))?(?:/|\z)?)?(?:([^?]*))? index.php?_route_=$2&site_language=$1 [L,QSA]
我如何更改此内容以使其适用于其他域名?我知道我需要用{HTTP_HOST}
之类的东西替换硬编码域,但我总是在我的URL或类似错误中有几个www.
。如果有人可以帮忙的话会很棒!
答案 0 :(得分:0)
您设置了错误的标记:[R,L=301]
而不是[R=301,L]
,您的网址被多次重写,并且您添加了多个www
。
要删除明确指定的域名,请修改您的规则
# delete trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ /$1 [R=301,L]
# Force SSL
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]