n2k
n2k

Reputation: 109

Getting 404 by using Laravel routes - rewrite not working

I'm using Laravel-5 framework and created the following route in the routes/web.php:

Route::get('/test', function () {
    return view('test');
});

After navigating to myapp.dev/test I get an Error 404:

Object not found! The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.

Navigating to myapp.dev/index.php/test works fine. So, looks like rewrite_mod is not working.

I'm using XAMP/Apache and rewrite_module is enabled in httpd.conf:

LoadModule rewrite_module modules/mod_rewrite.so

My larvavel's public folder contains a .htaccess file with following content:

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

    RewriteEngine On
    #DirectoryIndex index.php

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

The httpd-vhost configuration looks like the following:

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "s:/_dev/myapp/public"
    ServerName myapp.dev
    <Directory "s:/_dev/myapp/public">
        Allow from all
        Require all granted
        #Options Indexes        
    </Directory>    
    ErrorLog "logs/myapp.dev-error.log"
    CustomLog "logs/myapp.dev-access.log" common
</VirtualHost>

Any ideas what I missed?

Thanks

Upvotes: 0

Views: 639

Answers (1)

Josh Young
Josh Young

Reputation: 1366

I can not see any issues with our code however it could be a browser issue.

Have a look at this article which goes through the changes to browsers that cause issues with .dev domains.

https://medium.engineering/use-a-dev-domain-not-anymore-95219778e6fd

Upvotes: 1

Related Questions