質問編集履歴
1
routes.phpについてと、URLパスについて更新させていただきました。
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
cakephpの
|
1
|
+
cakephpで認証したら他のページにアクセスできない。
|
test
CHANGED
@@ -30,6 +30,16 @@
|
|
30
30
|
|
31
31
|
|
32
32
|
|
33
|
+
具体的には
|
34
|
+
|
35
|
+
C/xampp/htdocs/cake/src/Controller/UsersController(localhost/cake/Users/index)にはアクセスできますが
|
36
|
+
|
37
|
+
C/xampp/htdocs/cake/src/Controller/HomeController(localhost/cake/Home/index)や
|
38
|
+
|
39
|
+
localhost/cake/index.php(一番最初のデータベースがつながったかどのデータベース)にアクセスできません。
|
40
|
+
|
41
|
+
|
42
|
+
|
33
43
|
### 該当のソースコード
|
34
44
|
|
35
45
|
|
@@ -388,8 +398,178 @@
|
|
388
398
|
|
389
399
|
|
390
400
|
|
401
|
+
routes.php
|
402
|
+
|
403
|
+
|
404
|
+
|
391
405
|
```
|
392
406
|
|
407
|
+
<?php
|
408
|
+
|
409
|
+
/**
|
410
|
+
|
411
|
+
* Routes configuration
|
412
|
+
|
413
|
+
*
|
414
|
+
|
415
|
+
* In this file, you set up routes to your controllers and their actions.
|
416
|
+
|
417
|
+
* Routes are very important mechanism that allows you to freely connect
|
418
|
+
|
419
|
+
* different URLs to chosen controllers and their actions (functions).
|
420
|
+
|
421
|
+
*
|
422
|
+
|
423
|
+
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
|
424
|
+
|
425
|
+
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
426
|
+
|
427
|
+
*
|
428
|
+
|
429
|
+
* Licensed under The MIT License
|
430
|
+
|
431
|
+
* For full copyright and license information, please see the LICENSE.txt
|
432
|
+
|
433
|
+
* Redistributions of files must retain the above copyright notice.
|
434
|
+
|
435
|
+
*
|
436
|
+
|
437
|
+
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
438
|
+
|
439
|
+
* @link https://cakephp.org CakePHP(tm) Project
|
440
|
+
|
441
|
+
* @license https://opensource.org/licenses/mit-license.php MIT License
|
442
|
+
|
443
|
+
*/
|
444
|
+
|
445
|
+
|
446
|
+
|
447
|
+
use Cake\Core\Plugin;
|
448
|
+
|
449
|
+
use Cake\Routing\RouteBuilder;
|
450
|
+
|
451
|
+
use Cake\Routing\Router;
|
452
|
+
|
453
|
+
use Cake\Routing\Route\DashedRoute;
|
454
|
+
|
455
|
+
|
456
|
+
|
457
|
+
/**
|
458
|
+
|
459
|
+
* The default class to use for all routes
|
460
|
+
|
461
|
+
*
|
462
|
+
|
463
|
+
* The following route classes are supplied with CakePHP and are appropriate
|
464
|
+
|
465
|
+
* to set as the default:
|
466
|
+
|
467
|
+
*
|
468
|
+
|
469
|
+
* - Route
|
470
|
+
|
471
|
+
* - InflectedRoute
|
472
|
+
|
473
|
+
* - DashedRoute
|
474
|
+
|
475
|
+
*
|
476
|
+
|
477
|
+
* If no call is made to `Router::defaultRouteClass()`, the class used is
|
478
|
+
|
479
|
+
* `Route` (`Cake\Routing\Route\Route`)
|
480
|
+
|
481
|
+
*
|
482
|
+
|
483
|
+
* Note that `Route` does not do any inflections on URLs which will result in
|
484
|
+
|
485
|
+
* inconsistently cased URLs when used with `:plugin`, `:controller` and
|
486
|
+
|
487
|
+
* `:action` markers.
|
488
|
+
|
489
|
+
*
|
490
|
+
|
491
|
+
* Cache: Routes are cached to improve performance, check the RoutingMiddleware
|
492
|
+
|
493
|
+
* constructor in your `src/Application.php` file to change this behavior.
|
494
|
+
|
495
|
+
*
|
496
|
+
|
497
|
+
*/
|
498
|
+
|
499
|
+
Router::defaultRouteClass(DashedRoute::class);
|
500
|
+
|
501
|
+
|
502
|
+
|
503
|
+
Router::scope('/', function (RouteBuilder $routes) {
|
504
|
+
|
505
|
+
/**
|
506
|
+
|
507
|
+
* Here, we are connecting '/' (base path) to a controller called 'Pages',
|
508
|
+
|
509
|
+
* its action called 'display', and we pass a param to select the view file
|
510
|
+
|
511
|
+
* to use (in this case, src/Template/Pages/home.ctp)...
|
512
|
+
|
513
|
+
*/
|
514
|
+
|
515
|
+
$routes->connect('/', ['controller' => 'Pages', 'action' => 'display', 'home']);
|
516
|
+
|
517
|
+
|
518
|
+
|
519
|
+
/**
|
520
|
+
|
521
|
+
* ...and connect the rest of 'Pages' controller's URLs.
|
522
|
+
|
523
|
+
*/
|
524
|
+
|
525
|
+
$routes->connect('/pages/*', ['controller' => 'Pages', 'action' => 'display']);
|
526
|
+
|
527
|
+
|
528
|
+
|
529
|
+
/**
|
530
|
+
|
531
|
+
* Connect catchall routes for all controllers.
|
532
|
+
|
533
|
+
*
|
534
|
+
|
535
|
+
* Using the argument `DashedRoute`, the `fallbacks` method is a shortcut for
|
536
|
+
|
537
|
+
* `$routes->connect('/:controller', ['action' => 'index'], ['routeClass' => 'DashedRoute']);`
|
538
|
+
|
539
|
+
* `$routes->connect('/:controller/:action/*', [], ['routeClass' => 'DashedRoute']);`
|
540
|
+
|
541
|
+
*
|
542
|
+
|
543
|
+
* Any route class can be used with this method, such as:
|
544
|
+
|
545
|
+
* - DashedRoute
|
546
|
+
|
547
|
+
* - InflectedRoute
|
548
|
+
|
549
|
+
* - Route
|
550
|
+
|
551
|
+
* - Or your own route class
|
552
|
+
|
553
|
+
*
|
554
|
+
|
555
|
+
* You can remove these routes once you've connected the
|
556
|
+
|
557
|
+
* routes you want in your application.
|
558
|
+
|
559
|
+
*/
|
560
|
+
|
561
|
+
$routes->fallbacks(DashedRoute::class);
|
562
|
+
|
563
|
+
});
|
564
|
+
|
565
|
+
|
566
|
+
|
567
|
+
```
|
568
|
+
|
569
|
+
|
570
|
+
|
571
|
+
```
|
572
|
+
|
393
573
|
|
394
574
|
|
395
575
|
### 試したこと
|
@@ -413,3 +593,15 @@
|
|
413
593
|
|
414
594
|
|
415
595
|
cakephp3
|
596
|
+
|
597
|
+
|
598
|
+
|
599
|
+
### 追記
|
600
|
+
|
601
|
+
|
602
|
+
|
603
|
+
申し訳ありません。
|
604
|
+
|
605
|
+
routes.phpというものが大事だったのですね。
|
606
|
+
|
607
|
+
routes.phpを書き換えれば、Usersコントローラーの認証は関係なくなるのでしょうか。
|