Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The requested URL /ProjectName/users was not found on this server. Laravel

Tags:

php

laravel

I am following the quickstart of laravel and it said "type /users" but not working for me. I have wrote in the browser, http://DomainServer/ProjectName/users and it throws:

The requested URL /ProjectName/users was not found on this server. Laravel

I tried the following,

To enable the apache module mod_rewrite and also does not work.

like image 790
Luillyfe Avatar asked Jan 30 '14 13:01

Luillyfe


People also ask

What is htaccess in laravel?

htaccess file that is used to allow URLs without index. php . If you use Apache to serve your Laravel application, be sure to enable the mod_rewrite module.


1 Answers

Steps for Apache Web Server and Laravel in Linux Environment.

  1. Open httpd.conf

    sudo vim /etc/httpd/conf/httpd.conf
    # for debian users: /etc/apache2/apache2.conf
    
  2. Make sure the DocumentRoot is pointing to the laravel project's public directory

  3. Add the Directory element for that path and Allowoverride All... as follows

    DocumentRoot "/var/www/html/laravel/public/"
    
    <Directory "/var/www/html/laravel/public">
    Allowoverride All
    </Directory>
    
  4. Open .htaccess from ../laravel/public/ and make sure it has the following

    <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>
    
  5. Restart httpd services

    sudo service httpd restart
    
  6. Now http://DomainServer/users will work in your browser.

like image 172
Andrew Smith Avatar answered Oct 02 '22 17:10

Andrew Smith