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

trifek's avatar

Problem with run website on Laravel Valet - url not workings

Hi, I download my website from my serwer (php 8.2, apache). I need change something on this website. When I try run this project locally, on Laravel Valet I have problem with url,. Main page work fine, but when I click on ULR I have 404 not found. Laravel Valet has nginix - my hosting is apache. Maybe this is problem?

My .htaccess:

<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]

    # Fonts
    # Add correct content-type for fonts
    AddType application/vnd.ms-fontobject .eot
    AddType application/x-font-ttf .ttf
    AddType application/x-font-opentype .otf
    AddType application/x-font-woff .woff
    AddType image/svg+xml .svg

    ExpiresActive On
    ExpiresByType image/jpg "access plus 3 month"
    ExpiresByType image/jpeg "access plus 3 month"
    ExpiresByType image/gif "access plus 3 month"
    ExpiresByType image/png "access plus 3 month"
    ExpiresByType text/css "access plus 3 month"
    ExpiresByType application/pdf "access plus 3 month"
    ExpiresByType text/javascript "access plus 3 month"
    ExpiresByType application/javascript "access plus 3 month"
    ExpiresByType application/x-javascript "access plus 3 month"
    ExpiresByType application/x-shockwave-flash "access plus 3 month"
    ExpiresByType image/x-icon "access plus 3 month"
    ExpiresByType image/ico "access plus 3 month"

    ExpiresByType text/css "access plus 3 month"
    ExpiresByType text/css "now plus 1 month"
    ExpiresByType application/vnd.ms-fontobject "access plus 3 month"
    ExpiresByType application/x-font-ttf "access plus 3 month"
    ExpiresByType application/x-font-opentype "access plus 3 month"
    ExpiresByType application/x-font-woff "access plus 3 month"
    ExpiresByType image/svg+xml "access plus 3 month"
    ExpiresByType text/html "access plus 600 seconds"

    ExpiresDefault "access plus 2 days"

</IfModule>

How can I repair it?

0 likes
1 reply
LaryAI's avatar
Level 58

The issue you're facing is most likely due to the difference in web servers between your local environment (Laravel Valet with Nginx) and your server (Apache). The .htaccess file you provided is specific to Apache and may not work properly with Nginx.

To fix this issue, you can try the following steps:

  1. Remove the existing .htaccess file from your Laravel project.

  2. Create a new file named valet.conf in the root directory of your Laravel project.

  3. Open the valet.conf file and add the following configuration:

location / {
    try_files $uri $uri/ /index.php?$query_string;
}
  1. Save the valet.conf file.

  2. Restart Laravel Valet by running the following command in your terminal:

valet restart

This configuration will instruct Nginx to handle the routing in a similar way to Apache's .htaccess file.

After following these steps, try accessing your URLs again and see if the issue is resolved.

Please or to participate in this conversation.