[英]How should I configure '.htaccess' to redirect this?
我在 Hostinger 上有 3 個域,即
'puxir.com' | for hosting
'puxir.org' >> redirect to 'puxir.com'
'puxir.net' >> redirect to 'puxir.com'
以及網站上的 2 個子域:
m.puxir.com > for Mautic
w.puxir.com > for Drupal
目前我正在使用 3 個“.htaccess”文件:
[ public_html/.htaccess ]
RewriteEngine on
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^(m|w)\. [NC, OR]
RewriteCond %{HTTP_HOST} !\.com$ [NC]
RewriteRule ^(.*)$ https://w.puxir.com/%{REQUEST_URI} [L,R=301]
[ public_html/m/.htaccess ]
RewriteEngine on
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !\.com$ [NC]
RewriteRule ^(.*)$ https://m.puxir.com/%{REQUEST_URI} [L,R=301]
[ public_html/w/.htaccess ]
RewriteEngine on
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !\.com$ [NC]
RewriteRule ^(.*)$ https://w.puxir.com/%{REQUEST_URI} [L,R=301]
但現在我被困在試圖讓一些重定向只在 Apache 上工作。 例子:
(R1) http://www.puxir.org >> https://w.puxir.com/
[PASS!]
(R2) http://www.puxir.net >> https://w.puxir.com/
[PASS!]
(R3) http://www.puxir.com >> https://w.puxir.com/
[FAIL!]
(Mind the http/https negotiations above...)
我在這里做錯了什么?
你可以測試一下:
#[ public_html/.htaccess ]
RewriteEngine on
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^(m|w)\. [NC,OR]
RewriteCond %{HTTP_HOST} !\.com$ [NC]
RewriteRule ^(.*)$ https://w.puxir.com/%{REQUEST_URI} [L,R=301]
[NC, OR] 中的 [Space] 必須被取消。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.