Laravel 4 remove Index.php from URL

I need help with laravel 4 app. I need to remove Index.php from url. I tried the solution mentioned in the 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:)?

+4
source share
7 answers

FOR LAMP SERVER

Try the following steps:

  • Activate mod_rewrite module with

sudo a2enmod rewrite

  1. and restart apache

sudo service apache2 restart

  1. To use mod_rewrite from .htaccess files (which is very common), change the default VirtualHost with

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

  1. Find "DocumentRoot / var / www / html" and add the following lines below:

    <Directory "/var/www/html">` 
            AllowOverride All
    </Directory>
    
  2. nano CTRL-X, "y" ENTER.

  3. :

sudo service apache2 restart

+2

uncomment 'LoadModule rewrite_module modules/mod_rewrite.so' apache httpd.conf "public" .htaccess( )

<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>
+1

, , , .

( , ) - Terminal cd , "php artisan serve". . . ? http://localhost:8000 Laravel.

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

+1
source

it worked for me

<Directory "/var/www/html">` 
    AllowOverride All
</Directory>
+1
source

just go to apache settings folder, I use wamp so mine 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.

+1
source

The mod_rewrite apache module cannot be enabled by default. turn it on and try again.

0
source

Try the following:

a2enmod rewrite

And he will work

0
source

Source: https://habr.com/ru/post/1531446/


All Articles