我正在尝试从一个域重定向到另一个域。我想在所有情况下都使用htaccess文件重定向到“ https://myweb.com”。今天,我有以下代码:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.myweb.com.ar [OR]
RewriteCond %{HTTP_HOST} ^myweb.com.ar$
RewriteRule ^(.*)$ https://www.myweb.com/ [R=301,L]
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
让我们看看结果:
1)http://www.myweb.com >>好!
2)http://www.myweb.com.ar >>好!
3)https://www.myweb.com.ar >>错误,此处没有发生重定向。
我可以尝试解决什么问题?
提前谢谢!
答案 0 :(得分:0)
尝试重写,域名ar-> com,http-> https,www->非www,请求-> filename.php
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?myweb\.com\.ar [NC]
RewriteRule (.*) https://myweb.com/ [R=301,L]
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://myweb.com%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} ^www.myweb.com$ [NC]
RewriteRule ^(.*)$ https://myweb.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php