我有两个域名。假设是reports.test.com
和report.test.com
,它们指向一个Laravel5.0应用程序。有时在我的日志文件中,它会显示NotFoundHttpException in RouteCollection.php line 145:
错误。为什么我的应用程序要记录NotFoundHttpException?
这些是我的日志文件的位置
http://reports.test.com/storage/logs/laravel-2018-08-13.log
http://report.test.com/storage/logs/laravel-2018-08-13.log
发布于 2018-08-13 17:05:08
正确使用它的一种方法是使用一个域作为主域,将第二个域用作重定向到主域。
1.选择一个子域作为主域,另一个子域作为停放(次要)域。让我们说,reports
将是主要的。
2.将两个DNS A记录指向您的DNS服务器IP
A reports.test.com 123.123.123.123 # IP is just an example
A report.test.com 123.123.123.123 # IP is just an example
3.配置您的your服务器以重定向到您的主域。
例如,nginx服务器块将如下所示:
server {
listen 80;
server_name report.test.com;
# ...
rewrite ^ http://reports.test.com$request_uri? permanent;
}
# ... (your main app serverblock)
使用权限用户编辑服务器块# service nginx reload
后重新启动nginx。
4.确保.env文件使用主域
APP_URL="http://reports.test.com"
如果使用配置缓存,则使用部署用户更新缓存:php artisan config:cache
。
请注意,如果您愿意使用HTTPS,您可能希望根据需要进行编辑。
https://stackoverflow.com/questions/51828117
复制相似问题