我在过去2周面临这个问题(!!) 只有在生产env突然任何redirect() - > route()停止工作!
无论我做什么......它都不会工作。 我的prod网站是https协议,3周前它仍在工作,然后突然停止。
这是我的.htaccess文件:
# Enable Compression
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/plain
</IfModule>
<IfModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</IfModule>
# Leverage Browser Caching
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
<IfModule mod_headers.c>
<filesmatch "\.(ico|flv|jpg|jpeg|png|gif|css|swf)$">
Header set Cache-Control "max-age=2678400, public"
</filesmatch>
<filesmatch "\.(html|htm)$">
Header set Cache-Control "max-age=7200, private, must-revalidate"
</filesmatch>
<filesmatch "\.(pdf)$">
Header set Cache-Control "max-age=86400, public"
</filesmatch>
<filesmatch "\.(js)$">
Header set Cache-Control "max-age=2678400, private"
</filesmatch>
</IfModule>
<IfModule mod_headers.c>
# Set XSS Protection header
Header set X-XSS-Protection "1; mode=block"
</IfModule>
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 2 days"
ExpiresByType image/jpeg "access plus 2 days"
ExpiresByType image/gif "access plus 2 days"
ExpiresByType image/png "access plus 2 days"
ExpiresByType text/css "access plus 2 days"
ExpiresByType application/pdf "access plus 2 days"
ExpiresByType text/x-javascript "access plus 2 days"
ExpiresByType application/x-shockwave-flash "access plus 2 days"
ExpiresByType image/x-icon "access plus 2 days"
ExpiresByType text/html "access plus 2 days"
ExpiresDefault "access plus 2 days"
</IfModule>
## EXPIRES CACHING ##
## EXPIRES CACHING ##
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Credentials "true"
Header set Access-Control-Allow-Methods "GET, PUT, POST, DELETE, OPTIONS"
#Header set Access-Control-Max-Age "1000"
Header always append X-Frame-Options "SAMEORIGIN"
# Header set Connection keep-alive
</IfModule>
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
Options +FollowSymLinks
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]
# Force SSL
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteCond %{HTTP_HOST} ^testm.com
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
这是我的控制器代码,重定向到路由:
.....
return redirect()->route('admin.index.get')->withInput($request->only('admin', 'remember'));
.....
这是我的routes.php:
Route::group(['middleware' => ['auth','roles','custom-throttle','web'],'roles' => ['administrator'],'prefix' => 'admin', 'as' => 'admin.'], function() {
Route::controller('/', 'AdminController', [
//Basic
'getIndex' => 'index.get'
]);
});
我在httpd.conf和Vhost中都有AllowOverride All。
有什么问题?为什么它不起作用?
答案 0 :(得分:0)
所以,经过大量的等待时间......我发现了问题,希望它能帮助将来的任何人。
我正在使用AWS Elastic Beanstalk, 我将带有我的项目版本的zip文件上传到我的Elastic Beanstalk环境,EB将其解压缩并上传到我的EB实例,这样我就可以在我的应用程序中有超过1个实例(服务器),我不需要上传然后,每个版本分别连接到负载均衡器,将请求流重定向到我的应用程序。
发生的事情是,在我的env文件配置中,会话驱动程序是&#34; file&#34;类型,这意味着它保存项目位置(意味着在服务器上)的本地存储文件夹中的所有会话,问题是当我尝试登录时,会话已创建,但后来我从另一个实例获得响应(因为负载均衡器)当然没有会话...
因此,对于任何将遇到此特定问题的人,只需将会话驱动程序更改为memcached / redis / database