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 web app on AWS EC2 keep going down?

I'm relatively new to AWS and I've deployed a web app on an EC2 instance located in the us-east-2 region. I've also set up...

What’s the Best AI Tool for Coding? DeepSeek or Sonnet?

Hey everyone, I'm pretty new to coding and have never written a line of code. I've made a few apps with DeepSeek but it's...

What’s the Best Endpoint and User Management Solution for a Small Business with Remote Access Needs?

Hey everyone! I'm currently helping out a small family-run business with their IT needs, and I'm on the lookout for a budget-friendly endpoint and...

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