Laravel 5.2 redirect() - > route()不能在生产中工作
问题描述:
我在过去的2周内遇到这个问题(!!) 只有在生产env时,突然任何重定向() - > route()停止工作!Laravel 5.2 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'));
.....
Here is my 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。
出了什么问题?为什么它不工作?
答
因此,经过了很长时间......我发现这个问题,希望这对未来的任何人都有帮助。
进出口使用AWS弹性魔豆, 我上传的zip文件与我的项目版本到我的弹性魔豆环境和EB,并上传解压到我的EB实例/ S,这样的情况下,我有更多然后1个实例(服务器)到我的应用程序,我不需要分别上传版本到每一个,所有的实例连接到负载平衡器,重定向请求流到我的应用程序。
发生的事情是,在我的env文件配置中,会话驱动程序是“文件”类型,这意味着它将所有会话本地保存在项目位置(意味着在服务器上)的存储文件夹中,问题出在我尝试登录,会话创建,但后来我从另一个实例获得响应(因为负载平衡器),当然没有会话那里...
因此,任何人都将永远面对这个具体问题,只需将会话驱动程序更改为memcached/redis/database
您会更详细地介绍它如何不起作用吗? I,E。你看到任何错误页面?你在错误日志中也看不到任何错误,等等。 – Codemole
@Codemole,不,没有错误,错误日志是干净的,如果我检查访问日志,我看到/ admin url有302个HTTP代码。 –
你尝试过'php artisan config:cache'吗?或“路线:清除”?也许这是与缓存。 –