我有一個OpenCart多層安裝,這就是爲什麼我有幾個域指向同一個服務器文件夾。在這個文件夾中,我有一個.htaccess
文件,我只能使用其中一個域(在這種情況下:city-gardener.com
)。在一個域中使用一個.htaccess文件
下面是代碼:
# 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}
之類的東西替換硬編碼的域名,但我總是會在我的網址或類似錯誤中出現幾個www.
。如果有人能幫忙,會很棒!
什麼是這一點,不工作的示例網址? – anubhava
一個域名是city-gardener.com域名,另一個域名是.de域名(diestadtgaertner.de) –