3

Hello Everyone I am working on my project which in on Laravel 5.2. I have setup my project on my local machine but its now working without adding index.php in url.

I request with the url :-

http://localhost/project_folder/admin

While I am trying to run without index.php and run my url it gives me following error.

Not Found

The requested URL /project_folder/admin was not found on this server.

For this I did following steps : 1) Give permission (777) to storage and cache folder. 2) I Go to path /etc/apache2/sites-available/000-default.conf and edit it, now it look something like this.

<VirtualHost *:80>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    #ServerName www.example.com

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf

<Directory /var/www/html>
     Options Indexes FollowSymLinks MultiViews
         AllowOverride All
         Order allow,deny
         allow from all
</Directory>
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

In my .htaccess file have following code.

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

    RewriteEngine On

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    #RewriteRule ^(.*)/$ /$1 [L,R=301]
    RewriteRule ^(.*)/$ /moduleTesting/$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

Please suggest me if I forget any requirement or anything else.

3
  • There is no DirectoryIndex index.php in your apache config. Apache doesn't know what the default file is that it should open when there is no file provided by the URL Commented Nov 21, 2016 at 14:06
  • Possible duplicate of How to enable mod_rewrite for Apache 2.2 Commented Nov 21, 2016 at 14:10
  • Did you start apache services. Commented Nov 21, 2016 at 14:15

1 Answer 1

4

please enable mode rewrite. Please ensure that you have mod rewrite enable on your system.(search for mod_rewrite in info.php having code)

<?php
phpinfo();
?>

in terminal run command:

$ sudo a2enmod rewrite
Sign up to request clarification or add additional context in comments.

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.