正在显示
3 个修改的文件
包含
16 行增加
和
6 行删除
@@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
2 | 2 | ||
3 | namespace App\Http\Controllers; | 3 | namespace App\Http\Controllers; |
4 | 4 | ||
5 | +use App\Fun; | ||
5 | use Illuminate\Foundation\Auth\Access\AuthorizesRequests; | 6 | use Illuminate\Foundation\Auth\Access\AuthorizesRequests; |
6 | use Illuminate\Foundation\Bus\DispatchesJobs; | 7 | use Illuminate\Foundation\Bus\DispatchesJobs; |
7 | use Illuminate\Foundation\Validation\ValidatesRequests; | 8 | use Illuminate\Foundation\Validation\ValidatesRequests; |
@@ -18,8 +19,13 @@ class Controller extends BaseController | @@ -18,8 +19,13 @@ class Controller extends BaseController | ||
18 | * @author:dc | 19 | * @author:dc |
19 | * @time 2023/1/16 9:22 | 20 | * @time 2023/1/16 9:22 |
20 | */ | 21 | */ |
21 | - public function redirect($url){ | ||
22 | - $url = urldecode($url); | 22 | + public function redirect(){ |
23 | + $url = urldecode(request()->get('url')); | ||
24 | + | ||
25 | + if(empty($url)){ | ||
26 | + Fun::abort(); | ||
27 | + } | ||
28 | + | ||
23 | if(!preg_match("/^http(s?):\/\//",$url)){ | 29 | if(!preg_match("/^http(s?):\/\//",$url)){ |
24 | $url = 'http://'.$url; | 30 | $url = 'http://'.$url; |
25 | } | 31 | } |
@@ -143,7 +143,7 @@ class Index extends Base | @@ -143,7 +143,7 @@ class Index extends Base | ||
143 | $urls) | 143 | $urls) |
144 | ){ | 144 | ){ |
145 | foreach ($urls[1] as $k=>$url){ | 145 | foreach ($urls[1] as $k=>$url){ |
146 | - $_url = str_replace($url,'/redirect-'.urlencode($url),$urls[0][$k]); | 146 | + $_url = str_replace($url,'/redirect?url='.urlencode($url),$urls[0][$k]); |
147 | $data['html'] = str_replace($urls[0][$k],$_url,$data['html']); | 147 | $data['html'] = str_replace($urls[0][$k],$_url,$data['html']); |
148 | } | 148 | } |
149 | } | 149 | } |
@@ -66,10 +66,14 @@ Route::get('/blog', [\App\Http\Controllers\V2\Index::class,'blog']); | @@ -66,10 +66,14 @@ Route::get('/blog', [\App\Http\Controllers\V2\Index::class,'blog']); | ||
66 | Route::get('/blog/{id}', [\App\Http\Controllers\V2\Index::class,'blog_info'])->where('id','\d+'); | 66 | Route::get('/blog/{id}', [\App\Http\Controllers\V2\Index::class,'blog_info'])->where('id','\d+'); |
67 | // 单页 | 67 | // 单页 |
68 | Route::get('/page/{key}', [\App\Http\Controllers\V2\Index::class,'page'])->where('key','[a-z_\-\d]{2,}'); | 68 | Route::get('/page/{key}', [\App\Http\Controllers\V2\Index::class,'page'])->where('key','[a-z_\-\d]{2,}'); |
69 | -// 单页的另一种方式 | ||
70 | -Route::get('/{key}', [\App\Http\Controllers\V2\Index::class,'page'])->where('key','[a-z_\-\d]{2,}'); | 69 | + |
71 | 70 | ||
72 | // 跳转页面 | 71 | // 跳转页面 |
73 | -Route::get('/redirect-{url}', [\App\Http\Controllers\Controller::class,'redirect']); | 72 | +Route::get('/redirect', [\App\Http\Controllers\Controller::class,'redirect']); |
73 | + | ||
74 | + | ||
75 | +// 单页的另一种方式 这个是通用的匹配 | ||
76 | +Route::get('/{key}', [\App\Http\Controllers\V2\Index::class,'page'])->where('key','[a-z_\-\d]{2,}'); | ||
77 | + | ||
74 | 78 | ||
75 | 79 |
-
请 注册 或 登录 后发表评论