How to fix '/' in caffinated moudule in laravel

  • I am creating a new laravel setting on localhost ( /var/www/html/ ) using the composer create-project laravel/laravel moduleTesting --prefer-dist .

  • Then I move all the files inside the folder to ( /var/www/moduleTesting/setup ), and then move all the files from the shared folder ( /var/www/moduleTesting/setup/public ) to the testTesting folder ( /var/www/html/moduleTesting ).

  • I changed the path to the bootstrap file in the index.php file, which is located in the moduleexample.dev folder ( /var/www/html/moduleTesting/ ).

    DIR required. '/setup/bootstrap/autoload.php'; $ app = require_once DIR . '/../../laravel_setup/bootstrap/app.php';

  • I also set the permission of the folder /var/www/moduleTesting/setup/bootstrap/cache and /var/www/moduleTesting/setup/storage

  • Then I run the composer dump-autoload in the at terminal ( /var/www/moduleTesting/ ).

  • Then I try to run the url in the browser and I see the laravel application's welcome page.

  • Then I install the caffeinated / modules module package. Start by installing the package through Composer.

     composer require caffeinated/modules 

    Once this operation is completed, simply add both the service provider object and the facade classes to the project /var/www/html/moduleTesting/setup/config/app.php file:

    Service provider

     Caffeinated\Modules\ModulesServiceProvider::class, 

    Facade

     'Module' => Caffeinated\Modules\Facades\Module::class, 
  • After a successful installation, I create a new module using the make:module Admin command and follow the simple steps of the step, and it is successfully created and launched by clicking the URL http: // localhost / moduleTesting / admin '.

Question

Now the problem is that I am running the url. http: // localhost / moduleTesting / admin 'it works successfully, but when I run' http: // localhost / moduleTesting / admin '(add' / 'only at the end of the same URL), it now works and redirect me on url ' http: // localhost / admin '

Anyone know please help me solve this problem. In the same node, if you load the setting on the server to an internal folder and run the same URL, it also redirects me.

+5
source share
1 answer

Perhaps this is because .htaccess redirects trailing slashes to URLs without a slash.

In this section, in your .htaccess file, Apache redirects everything with a trailing slash — if not a folder — to its beginning. This causes problems because the project public is in the directory.

 RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)/$ /$1 [L,R=301] 

Replace the second rule:

 RewriteRule ^(.*)/$ /moduleTesting/$1 [L,R=301] 

Note: it is better not to use the directory as your general purpose because such problems occur. You better create a fake local domain, for example: module-test.dev or something else.

0
source

Source: https://habr.com/ru/post/1258881/


All Articles