Back

Router not working on production server


Hi everyone

I've an annoying issue. I have a prefix route => mydomain.com/app/ and when I go to this link it shows me the application. But If I want to go to this link => mydomain.com/app/contact then I have a 404 error.

I can't figure it out, does anyone know how to solve this?

##web.php

 Route::get('/contact', function() {
     return "hallo";
 });

##.htaccess

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>
RewriteEngine On
RewriteBase /app/

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

##nginx.conf

location /app {
        alias /folder/to/laravel/public;
        index index.php index.html index.htm;

            location ~ \.php$ {
                include ./fastcgi.conf;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_param SCRIPT_FILENAME $request_filename;
            }

     # try_files $uri $uri/ /index.php;
    }

Thanks!

henrik-nordstrom replied 4 months ago

Try removing the leading slash:

 Route::get('contact', function() {
     return "hallo";
 });
yawuar replied 4 months ago

It still returns a 404 error page.


Sign in to participate in this thread!



We'd like to thank these amazing companies for supporting us