remove index.php in laravel code example
Example 1: remove index.php laravel in linux server
Inside /etc/apache2/apache2.conf Replace
<Directory /var/www/> Options Indexes FollowSymLinks AllowOverride None Require all granted
to
<Directory /var/www/> Options Indexes FollowSymLinks AllowOverride All Require all granted
and
<Directory /usr/share> AllowOverride None Require all granted
to
<Directory /usr/share> AllowOverride All Require all granted
Run these commands
sudo a2enmod rewrite
sudo service apache2 restart
Inside your .htaccess file
DirectoryIndex index.php
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]
RewriteRule .? %{ENV:BASE}/index.php [L]
</IfModule>
Example 2: laravel remove index.php from url
laravel remove index.php from url
Example 3: laravel delete index
Schema::table('geo', function (Blueprint $table) {
$table->dropIndex(['state']);
});