4

I'm having a problem with my laravel application using VirtualHosts, I can see the home page of laravel but when I try to make a route like advkit.dev/login I get "The requested URL /login was not found on this server." So all my routes aren't working does anyone know what I need to change in my code to make routes work. I also have set debug to true and I only get the debuging console on the home page e.g advkit.dev no where else

route:

<?php

Route::get('/', function()
{
    return View::make('hello');
});

// login.blade.php
Route::get('/login', function() {
    return View::make('login');
});

hosts

127.0.0.1       www.localhost.com
127.0.0.2       advkit.dev

httpd-hosts file

<VirtualHost advkit.dev>
    DocumentRoot C:\wamp\www\advkit\public
    ServerName advkit.dev
</VirtualHost>
4
  • do you have your mod-rewrites set up properly ? I can't see anything wrong with your code or configuration. Commented Jun 27, 2015 at 1:48
  • I haven't changed anything in the rewrites what do I do Commented Jun 27, 2015 at 1:53
  • sometimes laravel does not work with the default configuration. In their website they have given another rewrite. Try this one. laravel.com/docs/5.0/configuration#pretty-urls Commented Jun 27, 2015 at 1:54
  • I'm using laravel 4.2 and that code didn't work Commented Jun 27, 2015 at 1:58

3 Answers 3

3

You can add the following lines in your .conf file.

<Directory /var/www/gloops/public>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
 </Directory>

After save the files and enable rewrite mode by the given command and restart the apache2 service.

sudo a2enmod rewrite
sudo service apache2 restart
Sign up to request clarification or add additional context in comments.

Comments

2

I had the same problem and the virtualhost setup given in the following answer worked for me: https://stackoverflow.com/a/33760330/4561150

<Directory "C:/myproject/mysubfolder/public">
   Options Indexes FollowSymLinks Includes ExecCGI
   AllowOverride All
   Require all granted
</Directory>

Comments

0

It sounds like Apache is ignoring your .htaccess file. You could fix that, but the better solution is to put the contents of that .htaccess file in your virtualhost. Then your virtualhost would look like this:

<VirtualHost advkit.dev>
    DocumentRoot C:\wamp\www\advkit\public
    ServerName advkit.dev

    <Directory C:\wamp\www\advkit\public>
        # Ignore the .htaccess file in this directory
        AllowOverride None

        # Rewrite URLs
        <IfModule mod_rewrite.c>
            <IfModule mod_negotiation.c>
                Options -MultiViews
            </IfModule>

            RewriteEngine On

            # Redirect Trailing Slashes
            RewriteRule ^(.*)/$ /$1 [L,R=301]

            # Handle Front Controller
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule ^ index.php [L]
        </IfModule>
    </Directory>
</VirtualHost>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.