Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

kayaz's avatar
Level 1

Laravel show me 404 error in domain catalog

I have shared hosting without ssh access. I transfer my Laravel project from localhost to domain catalog:

www.test.domain.com/laravel

My .htaccess

RewriteEngine on
RewriteBase /laravel

RewriteCond %{REQUEST_URI} !^/public
RewriteRule ^(.*)$ public/ [L]

In my .env file I set like this:

APP_URL=http://www.test.domain.com/laravel

And i get 404 Not Found error page from Laravel. It looks like something might be wrong with route.. In plesk i see this error

2019-09-08 05:20:44  Error   xx.xxx.xxx.xxx  404 GET /laravel/ HTTP/1.1

Any advice?

0 likes
3 replies
jlrdw's avatar

I have no idea about your entire htaccess file, but this works fine for me on local and server:

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On
    RewriteBase /laravel60/    <------use your rewrite base here.

    # 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
    RewriteRule ^ index.php [L]
</IfModule>
kayaz's avatar
Level 1

I have two .htaccess files - one is in the root directory. And the other in the public catalog.

http://www.test.domain.com/laravel/ - this gives me a 404 error

http://www.test.domain.com/laravel/public/ - this one work

My .htaccess:

  1. main
RewriteEngine on
RewriteBase / laravel

RewriteCond% {REQUEST_URI}! ^ / Public
RewriteRule ^ (. *) $ Public / [L]
  1. public catalog
<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
     RewriteRule ^ index.php [L]
</ IfModule>

If i change first file to this:

RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_URI} !^/public
RewriteRule ^(.*)$ public/ [L]

I get error:

Not Found
The requested document was not found on this server. 

Please or to participate in this conversation.