How To Remove index.php From Laravel Url

This is quite a common issue that can be caused by a few different things, all of which are very simple to fix.

If this is a fresh install then the first thing that you should check is your Apache conf file since this is likely the cause. Apaches conf file is usually located in “/etc/httpd/conf/httpd.conf”, but this may vary depending on your set-up. In this file you will need to modify the ‘Directory’ block on your virtual host. Update the contents of the directory block to contain the following

<Directory "/var/www/laravel/public">
     AllowOverride All
<Directory>

Your virtual host should look like this. Once you have added this to the conf file, save the file and restart Apache.

<VirtualHost *:80>
  ServerName www.laravel.com
  ServerAlias laravel.com
  DocumentRoot "/var/www/laravel/public
  <Directory "/var/www/laravel/public">
    Options FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>

Now you should now longer need to have index.php at the end of the url. If you have done the above and it still is not working then you will need to have a look at the rewrite rule in your .htaccess file to make sure it’s working correctly. If you do not have the mod_rewrite plugin installed then you will need to install it, but Im going to assume you have this installed since it is installed by default. The default .htaccess file generated by laravel contains some code that might be causing you issues. If you remove the following lines from your .htaccess the issue should immediately go away.

<IfModule mod_rewrite.c> <--remove
    <IfModule mod_negotiation.c> <--remove
        Options -MultiViews
    </IfModule> <--remove

    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> <--remove

Related Articles

Related Questions

Is My Computer Beyond Repair?

Hey, I'm in a bit of a mess here with my Windows 10 system. I have about 300 GB free on my 64-bit setup,...

WordPress Table of Contents Plus Not Working

I have been using this plugin for a while and i really like it. It seems to have completely stopped working recently. I can...

Function Keys Reversing Between Fn Actions And Normal

My keyboard has the usual F1 to F12 keys along the top. I use these for shortcuts in various applications. These keys also have...

3 COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Latest Tools

OpenAI Token Calculator

This tool is a simple OpenAI token calculator, web-based utility designed to help you quickly estimate the number of tokens in your text when...

List Sorting Tool

Welcome to our innovative list ordering and management tool. This next-level platform enables you to sort a list of items in ascending or descending...

Sudoku Solver

Welcome to our free online Sudoku solving tool, an interactive platform for puzzle enthusiasts seeking a break from a Sudoku conundrum. This advanced platform...

Apply Image Filters To Image

Digital imagery in the modern world is all about reinforcing emotions and stories behind each photo we take. To amplify this storytelling, we are...

Add Watermark To Image

As the world is increasingly consumed by digital media, protecting your original images is paramount. We are thrilled to introduce you to our innovative...

CSV To Xml Converter

Welcome to our CSV to XML converter tool, a convenient and user-friendly solution for all your data conversion needs. This versatile tool on our...

Latest Posts

Latest Questions