Browse Source

路由修改

moshaorui 3 weeks ago
parent
commit
2951887e11
2 changed files with 11 additions and 11 deletions
  1. 4 7
      app/Http/Middleware/MapCustomUrl.php
  2. 7 4
      routes/web.php

+ 4 - 7
app/Http/Middleware/MapCustomUrl.php

@@ -9,13 +9,10 @@ class MapCustomUrl
 {
     public function handle(Request $request, Closure $next)
     {
-        $path = $request->path();
-
-        // 检查是否是 /protetor-de-tela-de-vidro-temperado
-        if ($path === 'sobre') {
-            // 动态设置路由参数
-            $request->route()->setParameter('slug', 'sobre');
-        }
+//        $uri = $request->getRequestUri();
+//        dd($uri);
+//        $request->server->set('REQUEST_URI', '/pages/sobre');
+//        $request->server->set('pathInfo', '/pages/sobre');
 
         return $next($request);
     }

+ 7 - 4
routes/web.php

@@ -24,9 +24,11 @@ use App\Models\SitePage;
 */
 
 //巴西官网专用路由
-//$host = $_SERVER['HTTP_HOST']; // 获取当前域名
-//
-//if ($host == 'internal-demo-site.mietubl.com.cn') {
+$host = $_SERVER['HTTP_HOST']; // 获取当前域名
+
+if ($host == 'internal-demo-site.mietubl.com.cn') {
+    Route::get('/{slug}', [CollectionController::class, 'detail'])->name('collection.detail');
+
 //    Route::get('/{slug}', function ($slug) {
 //        // 查询数据库,将 category_slug 转换为对应ID
 //        $categoryId = DistProductCategory::where(function ($query) use ($slug) {
@@ -51,7 +53,8 @@ use App\Models\SitePage;
 //        $productController = new ProductController();
 //        return $productController->detail($slug);
 //    });
-//}
+
+}