htaccess - 将所有流量重定向到app.example.com

时间:2017-09-28 12:35:58

标签: apache .htaccess

我试图重定向我的应用程序,但我有一些问题。 我尝试过:

 Options +FollowSymLinks
RewriteEngine On  
RewriteCond %{HTTP_HOST} ^app.example.com [NC]
RewriteRule ^(.*)$ https://app.example.com/$1 [R=301,L]

RewriteRule .* index.html [L]

我想重定向来自:

的所有传入流量
app.example.com
www.app.example.com
http://app.example.com
https://www.app.example.com
to https://app.example.com

任何帮助?

1 个答案:

答案 0 :(得分:0)

RewriteEngine On
RewriteCond %{HTTP_HOST} !^app\.example\.com$ [NC]
RewriteRule (.*) http://app.example.com$1 [R=301,L]
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

//this redirect all not existing routes to index.html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]