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

How Can I Get Claude to Access My Google Drive Files?

I've connected Claude to my Google Drive and I have several Word documents stored there. However, when I ask Claude how many files it...

Help! My New SSD Keeps Booting to BIOS

Hey everyone! I recently upgraded from a 240GB SSD to a 1TB SATA drive. I used DiskGenius to clone my SSD and run the...

How can I get a program launcher like the one in Arch on Linux Mint?

I've recently installed Linux Mint on my MacBook Pro and fell in love with the program launcher in Arch Linux. In Arch, I could...

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

xAI Grok Token Calculator

This tool is a simple xAI Grok token calculator that helps you estimate the number of tokens your input text might consume when working...

DeepSeek Token Calculator

This tool is a straightforward DeepSeek token calculator, created to help you estimate how many tokens your text may use when working with DeepSeek...

Google Gemini Token Calculator

This tool is a simple Google Gemini token calculator, designed to help you estimate how many tokens your text might use with models in...

Meta LLaMA Token Calculator

This tool is a basic Meta LLaMA token calculator, designed to give you a fast estimate of how many tokens your input text might...

Anthropic Claude AI Token Calculator

This tool is a simple Claude token calculator, built to help you quickly estimate token usage when working with Anthropic’s Claude models. It’s an...

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

Latest Posts

Latest Questions