Results 1 to 4 of 4

Thread: [Laravel] Configure PHP routes and Apache .htaccess to work into a folder

  1. #1
    laravista is offline Utente AlterBlog
    Join Date
    Dec 2019
    Posts
    45

    Default [Laravel] Configure PHP routes and Apache .htaccess to work into a folder

    Hi All,
    now I configured Laravel to work into the laravel-5.6-test folder:



    but the second link does not work (404 Page not found)

    This is the .htaccess in the folder:

    Code:
    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /laravel-5.6-test
        RewriteRule ^(.*)$ public/$1 [L]
    </IfModule>
    and this is routes/web.php

    PHP Code:
    Route::get('/laravel-5.6-test', function () {
    return
    view('welcome');
    });

    Route::get('/laravel-5.6-test/test', function () {
    return
    'TEST';
    });

  2. #2
    alemoppo is offline AlterVista Staff
    Join Date
    Feb 2010
    Location
    IT
    Posts
    735

    Default

    There's someting wrong with the "/":

    Code:
    http://laravista.altervista.org/laravel-5.6-test/test
    ->
    https://laravista.altervista.org/membri/laravista/laravel-5.6-test/public/index.php
    I think the bold text should not be here, but i didn't investigate a lot about the reason, sorry.

    Bye!

  3. #3
    laravista is offline Utente AlterBlog
    Join Date
    Dec 2019
    Posts
    45

    Default

    Works now using this public/.htaccess configuration:

    Code:
    <IfModule mod_rewrite.c>
        <IfModule mod_negotiation.c>
            Options -MultiViews -Indexes
        </IfModule>
    
        RewriteEngine On
        
        # Handle Authorization Header
        RewriteCond %{HTTP:Authorization} .
        RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    
        # Redirect Trailing Slashes If Not A Folder...
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_URI} (.+)/$
        RewriteRule ^ %1 [L,R=301]
    
        # Handle Front Controller...
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteBase /laravel-5.6-test
        RewriteRule ^(.*)$ public/index.php/$1 [L]
    </IfModule>
    but only using the URLs into a new browser-tab via copy&paste, possible?

  4. #4
    laravista is offline Utente AlterBlog
    Join Date
    Dec 2019
    Posts
    45

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

SEO by vBSEO