Apache 从htaccess重写规则中删除硬编码URL
我有一个Apache 从htaccess重写规则中删除硬编码URL,apache,.htaccess,magento,mod-rewrite,Apache,.htaccess,Magento,Mod Rewrite,我有一个.htaccess和多个规则,还有3个是Magento商店的硬编码URL: 1)要从URL中删除端口号,站点运行在Docker容器中,Apache和Nginx在主机上运行,以将流量转发到正确的容器。由于某些原因,:80被添加到url,此规则将删除它: RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://domain.nl/$1 [L,R=301] 2)从url中删除index.php: RewriteCond %{THE_R
.htaccess
和多个规则,还有3个是Magento商店的硬编码URL:
1)要从URL中删除端口号,站点运行在Docker容器中,Apache和Nginx在主机上运行,以将流量转发到正确的容器。由于某些原因,:80
被添加到url,此规则将删除它:
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://domain.nl/$1 [L,R=301]
2)从url中删除index.php
:
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ https://domain.nl/$1 [R=301,L]
3)将/home
重定向到/
:
redirect 301 /home https://domain.nl
现在,我想在此Magento安装中运行多个存储,以便将多个域名链接到此安装。由于硬编码的URL,此
.htaccess
冲突。我试着让这些通用,但我最终有500个错误。如何使这3条规则通用?找到了!经过多次尝试,并用curl检查了标题,我终于找到了答案。但它的配置仍然有点奇怪,因为Nginx将主机上的所有内容重定向到Docker容器中的Apache
1)
2)
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ https://%{HTTP_HOST}/$1 [R=301,L]
RewriteRule ^home/?$ https://%{HTTP_HOST}/ [nc,R=301,L]
3)
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ https://%{HTTP_HOST}/$1 [R=301,L]
RewriteRule ^home/?$ https://%{HTTP_HOST}/ [nc,R=301,L]