4

I need some help with laravel 4 application i need to remove Index.php from url i have tried the solution that has been mentioned in laravel documentation

Pretty URLs
Apache

The framework ships with a public/.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.

If the .htaccess file that ships with Laravel does not work with your Apache installation, try this one:

Options +FollowSymLinks
RewriteEngine On

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

any Suggestions :) ?

Ahmad abdallah
  • 103
  • 1
  • 7

7 Answers7

2

FOR LAMP SERVER

Try the following steps,

  1. Activate the mod_rewrite module with,

sudo a2enmod rewrite

  1. and restart the apache

sudo service apache2 restart

  1. To use mod_rewrite from within .htaccess files (which is a very common use case), edit the default VirtualHost with

sudo nano /etc/apache2/sites-available/000-default.conf

  1. Search for “DocumentRoot /var/www/html” and add the following lines directly below:

    <Directory "/var/www/html">` 
            AllowOverride All
    </Directory>
    
  2. Save and exit the nano editor via CTRL-X, “y” and ENTER.

  3. Restart the server again:

sudo service apache2 restart

Flexo
  • 87,323
  • 22
  • 191
  • 272
Vinod VT
  • 6,946
  • 11
  • 51
  • 75
2

this worked for me

<Directory "/var/www/html">` 
    AllowOverride All
</Directory>
Pankaj Garg
  • 1,272
  • 15
  • 21
1

uncomment 'LoadModule rewrite_module modules/mod_rewrite.so' in apache httpd.conf in 'public' folder check .htaccess file (created by default)

<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>
vuhung3990
  • 6,353
  • 1
  • 45
  • 44
1

just go to your apache settings folder, i use wamp so myne is

C:/wamp/bin/apache/apache2.4.9/conf/httpd.conf - file

   // located on line 154 precisely... 

    #LoadModule rewrite_module modules/mod_rewrite.so  

   // to 

    LoadModule rewrite_module modules/mod_rewrite.so 

restart WAMP and BOOM!.. it works.

BurningLights
  • 2,387
  • 1
  • 15
  • 22
Ande Caleb
  • 1,163
  • 1
  • 14
  • 35
0

mod_rewrite apache module may not be enabled by default. enable it and retry.

Try
  • 31
  • 6
0

Try this:

a2enmod rewrite

And it will works

TuGordoBello
  • 4,350
  • 9
  • 52
  • 78
0

I have read long posts and threads but nothing works then i found this and it works for me.

The easiest way to do this (and the way I always use) is to open up your Command prompt or Terminal and cd into the main directory of your project then run "php artisan serve". That's it. You're done. Don't believe me? Check out http://localhost:8000 and admire your Laravel work.

http://michaelbrooks.co.uk/post/laravel-localhost-removing-public-index-php

owais
  • 4,752
  • 5
  • 31
  • 41
  • 4
    Your answer is to use the built in *development* server? That's really bad advice. – Mr_Chimp Aug 08 '14 at 12:37
  • here user have not mentioned that he is on the production server. I think so its best option to use when you are development mode. – owais Aug 09 '14 at 13:48
  • 1
    Yes, your solution works properly. But what if I want to run in virtual host, i.e. I create a custom url? – Mostafiz Rahman Sep 30 '14 at 19:14