From 0f065ef202ef700fb60c7294dabf6e952ee0270c Mon Sep 17 00:00:00 2001 From: printempw Date: Tue, 7 Nov 2017 21:40:53 +0800 Subject: [PATCH] Try to avoid using site url which ends with index.php #101 --- app/Http/Controllers/AdminController.php | 8 +++++++- app/Http/Controllers/SetupController.php | 11 +++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php index c1cd44e8..8430aa54 100644 --- a/app/Http/Controllers/AdminController.php +++ b/app/Http/Controllers/AdminController.php @@ -108,8 +108,14 @@ public function options() $form->text('site_url') ->hint() ->format(function ($url) { - if (ends_with($url, '/')) + if (ends_with($url, '/')) { $url = substr($url, 0, -1); + } + + if (ends_with($url, '/index.php')) { + $url = substr($url, 0, -10); + } + return $url; }); diff --git a/app/Http/Controllers/SetupController.php b/app/Http/Controllers/SetupController.php index 6c7e4f9b..83e49e8a 100644 --- a/app/Http/Controllers/SetupController.php +++ b/app/Http/Controllers/SetupController.php @@ -57,7 +57,14 @@ public function finish(Request $request) Log::info("[SetupWizard] Tables migrated."); Option::set('site_name', $request->input('site_name')); - Option::set('site_url', url('/')); + + $siteUrl = url('/'); + + if (ends_with($siteUrl, '/index.php')) { + $siteUrl = substr($siteUrl, 0, -10); + } + + Option::set('site_url', $siteUrl); // register super admin $user = User::register( @@ -137,7 +144,7 @@ public function doUpdate() Artisan::call('view:clear'); } catch (\Exception $e) { Log::error('Error occured when processing view:clear', $e); - + File::cleanDirectory(storage_path('framework/views')); }