私のアプリはherokuでホストされており、私はCakephp APIを使用しています。 https://wwwにリダイレクトしてください。 wwwを強制する。サブドメイン。.htaccesとcakephpを使ってhttpからhttpsにドメインをリダイレクトする方法
そして、2つのドメインが同じアプリを指しています。
私は、次のコードを持って/app/.htaccess
RewriteEngine on
RewriteBase/
#apply if no https
RewriteCond %{HTTPS} off
#Ignore when is local env or any staging env
RewriteCond %{HTTP_HOST} !^local(.*) [NC]
RewriteCond %{HTTP_HOST} !^(.*)heroku(.*) [NC]
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]
#apply if https
RewriteCond %{HTTPS} on
#Ignore when is local env or any staging env or subdoamin is www.
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} !^local(.*) [NC]
RewriteCond %{HTTP_HOST} !^(.*)heroku(.*) [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]
#default from cakephp
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
に私は/app/webroot/.htaccess
RewriteEngine On
RewriteBase/
#redirect any request from .poa.br to .com.br
RewriteCond %{HTTP_HOST} ^(.*)example\.poa\.br$ [NC]
RewriteRule ^(.*)$ https://www.example.com.br/$1 [NE,R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule^index.php [L]
で、次のコードを持っていますが、それはdoesnの仕事。ただ、リクエストがhttps://www.example.com.brにリダイレクトされ、次のとおりです。
https://www.example.com.br
https://www.example.poa.br
http://www.example.poa.br
このオプションは、ドメインに行くが、プリフィックスHTTPSをせずに。
http://www.example.com.br
他のオプションは(DNS_PROBE_FINISHED_NXDOMAINを返す)は動作しません:
https://example.com.br
http://example.com.br
https://example.poa.br
http://example.poa.br
こんにちはKonjesh!それはうまくいかなかった。 テストでループを作成しているため、書き換えモジュールがオンになっていると思います。 –
あなたの提案の結果は私のコードと同じです。 –