Laravel 4 remove Index.php from URL

2019-01-28 04:07发布

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 :) ?

7条回答
beautiful°
2楼-- · 2019-01-28 04:53

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

查看更多
登录 后发表回答