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

Why Does My PC Keep Turning Off Under Load?

Hey everyone, I'm having a frustrating problem with my PC shutting down unexpectedly when both the CPU and GPU are under load, even if...

What Do You Think About the New EU Accessibility Law?

With the new EU accessibility law coming into effect, I'm feeling a bit overwhelmed. It seems nearly impossible for many websites to meet all...

How can I control the ARGB on my MSI MAG PANO M100R PZ case?

I recently purchased an MSI MAG PANO M100R PZ case about a month and a half ago, but I'm having trouble controlling the ARGB...

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

Online Hash Generator – String to Hash Converter

Need to quickly generate a hash from a string? Whether you're verifying file integrity, securing data, or just experimenting with cryptographic tools, this simple...

Convert CSV To HTML Table

Need to quickly turn CSV data into an HTML table? Whether you're copying data from Excel, Google Sheets, or another spreadsheet, this tool makes...

Student Group Randomizer

Creating fair and balanced groups in the classroom can be time-consuming — especially when you're trying to avoid repetition, manage different skill levels, or...

Random Group Generator

Need to split a list of people, items, or ideas into random groups? Our free Random Group Generator makes it quick and easy. Whether...

Flip Text Upside Down – Free Online Tool

Ever wanted to flip your text upside down just for fun or to grab someone’s attention in a creative way? This free online Upside...

Raffle Ticket Generator

If you're running a fundraiser, charity draw, or local event and need raffle tickets fast, this free online tool lets you generate and print...

Latest Posts

Latest Questions