5
votes
  1. I make a fresh setup of laravel on localhost (/var/www/html/) with command composer create-project laravel/laravel moduleTesting --prefer-dist.

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

  3. I changed bootstrap file path in index.php file placed in moduleexample.dev folder(/var/www/html/moduleTesting/).

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

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

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

  6. Then I try to run URL in the browser, and I see the welcome page of laravel app.

  7. Then I install module package caffeinated/modules Begin by installing the package through Composer.

    composer require caffeinated/modules
    

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

    Service Provider

    Caffeinated\Modules\ModulesServiceProvider::class,
    

    Facade

    'Module' => Caffeinated\Modules\Facades\Module::class,
    
  8. After successful installation, I create a new module by command make:module Admin and follow easy steps steps and it created successfully and run by hitting URL http://localhost/moduleTesting/admin'.

Issue

Now the problem is when I run URL.'http://localhost/moduleTesting/admin' it runs successfully but when i run 'http://localhost/moduleTesting/admin'(add '/' only at the end of the same url) it does now work and redirect me to url 'http://localhost/admin'

Does anybody know, please help me how to solve this issue, On the same node if upload the setup on the server in a inner folder and run the same url it also redirect me.

1

1 Answers

0
votes

This is probably because .htaccess redirects trailing slashes to an URL without a traling slash.

In this section in your .htaccess file, Apache redirects everything with a trailing slash - if not a folder - to its origin. This causes trouble, because the public of the project is located at a directory.

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

Replace the second rule with:

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

Note: it is better not using a directory as your public destination because these kinds of problems occur. You should be better of creating a fake local domain, like: module-test.dev or something.