0

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 my@mail.com
    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

n2k
  • 109
  • 2
  • 13
  • did you restart apache? Also see: https://stackoverflow.com/questions/869092/how-to-enable-mod-rewrite-for-apache-2-2 – Adam Rodriguez Nov 18 '18 at 19:58
  • Yes, i restarted the server. Unfortunately, I did not found a solution in your linked post. – n2k Nov 18 '18 at 20:32
  • 1
    It might be a shorter way to migrate your project to vagrant/Laravel homestead. You will be working way easier! – Zoli Nov 18 '18 at 21:27
  • Thanks for the tip. Sounds cool. I will have a look. But if somebody have a solution to my issue it would be great, anyway :) Because I probably will run into such an issue on productive server side later. – n2k Nov 18 '18 at 21:45
  • Have you tried to add `AllowOverride All` inside `` in httpd-vhost configuration ? Don't forget to restart your server. – Teguh Suryo Santoso Nov 19 '18 at 02:58
  • Yes I tried it. This will lead to a 403 (Access Forbidden). After reading the article posted in answer of Josh I thought it might have something to do with this .dev issue (in newer browsers it's only possible to use .dev only with https due to HSTS hosts entry). But I also tried to use a completely arbitrary TLD. Still 403 after AllowOverride All. – n2k Nov 19 '18 at 20:41

1 Answers1

1

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

Josh
  • 1,316
  • 10
  • 26
  • Thanks for your feedback. Very interesting article. But unfortunately this does not seem to be my issue (not yet ;) ). After reading this article I tried to use a completely arbitrary gTLD. I also tried it in several browsers including Chrome, Firefox, IE, Vivaldi (Chromium). Same issue. – n2k Nov 19 '18 at 20:39