Laravel 4 remove Index.php from URL

六眼飞鱼酱① 提交于 2019-11-29 14:43:18
Vinod VT

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

this worked for me

<Directory "/var/www/html">` 
    AllowOverride All
</Directory>

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>

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

Andaeiii

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.

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

Try this:

a2enmod rewrite

And it will works

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!