.htaccess zf2 apache aws elb http到https
我看过: 我的负载平衡器侦听端口如下所示:.htaccess zf2 apache aws elb http到https,.htaccess,amazon-web-services,amazon-ec2,zend-framework2,amazon-elb,.htaccess,Amazon Web Services,Amazon Ec2,Zend Framework2,Amazon Elb,我看过: 我的负载平衡器侦听端口如下所示: HTTP (incoming) -> HTTP (instance) HTTPS (incoming) -> HTTP (instance) 以下是我到目前为止的情况: RewriteEngine On # The following rule tells Apache that if the requested filename # exists, simply serve it. RewriteCond %{REQUEST_F
HTTP (incoming) -> HTTP (instance)
HTTPS (incoming) -> HTTP (instance)
以下是我到目前为止的情况:
RewriteEngine On
# The following rule tells Apache that if the requested filename
# exists, simply serve it.
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule !/elbcheck.html https://%{SERVER_NAME}%{REQUEST_URI}
RewriteRule ^.*$ - [NC,L]
# The following rewrites all other queries to index.php. The
# condition ensures that if you are using Apache aliases to do
# mass virtual hosting, the base path will be prepended to
# allow proper resolution of the index.php file; it will work
# in non-aliased environments as well, providing a safe, one-size
# fits all solution.
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]
这可以将http重定向到https,但它只会转到索引页。它没有启动应用程序,所有其他页面返回为404
任何建议都将不胜感激,我已经在这个问题上花费了太长时间
***************更新***************
以下是我的.htaccess
最终的样子:
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTP_USER_AGENT} !^ELB-HealthChecker
RewriteRule (.*) https://sitename.com%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
# The following rule tells Apache that if the requested filename
# exists, simply serve it.
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
# The following rewrites all other queries to index.php. The
# condition ensures that if you are using Apache aliases to do
# mass virtual hosting, the base path will be prepended to
# allow proper resolution of the index.php file; it will work
# in non-aliased environments as well, providing a safe, one-size
# fits all solution.
RewriteRule ^.*$ index.php [NC,L]
希望这有帮助 我认为这是最好的解决方案,而不是提出我自己的答案,并在适当的时候给予赞扬
还要确保通过AWS控制台将侦听器添加到ELB。端口80和端口443的侦听器