Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess zf2 apache aws elb http到https_.htaccess_Amazon Web Services_Amazon Ec2_Zend Framework2_Amazon Elb - Fatal编程技术网

.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的侦听器