Search code examples
phpapachelaravel

Remove index.php from the url with laravel 5


I checked many posts here about removing index.php from url but I could not get the desired results, I already added my local url site name to virtual hosts file (I use wamp) and when I write url like this it work http://first-app.com

My problem when I navigate to another folder like "songs" this url does not work, I get url not found

http://first-app.com/songs

while if I used index.php it work

http://first-app.com/index.php/songs

here is my httpd-vhosts.conf file:

<Directory C:\wamp\www\composer-demo\first-app\public>
Order Deny,Allow 
Allow from all
</Directory>

<VirtualHost *:80>
DocumentRoot "C:\wamp\www\composer-demo\first-app\public"
ServerName first-app.com
</VirtualHost>

Can that be solved from modifying this file ? or I need to modify .htaccess file located at the public folder ? here it is:

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

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

Solution

  • All I need was to enable rewrite_module in the apache server then restart, since I use wamp I only selected the module from the list menu