Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

roguelinkz's avatar

Remove index.php from urls

Hello,

I have a CentOS machine with Apache and I'm trying to deploy a Laravel project I've been working on. The problem is that when I try to access the homepage (mysite.com/) everything works fine but if I try going to any other route (i.e., mysite.com/example) it doesn't work unless I add index.php to it (mysite.com/index.php/example). After searching I found multiple answers but none seemed to work.

My project structure is the default in Laravel and inside the public folder my .htaccess file looks something like this:

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

I've also changed my httpd.conf file by adding this:

<Directory "/var/www/html/mysite/public/">
    Options FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

It still doesn't seem to work. Is there anything I'm doing wrong?

0 likes
2 replies
roguelinkz's avatar

Nevermind, I found the solution via a friend. Even if the mod_rewrite module showed enabled, it was not being loaded in the httpd.conf. I added

LoadModule rewrite_module modules/mod_rewrite.so

to the end of it and it works now.

biishmar's avatar

@roguelinkz

At the root, rename server.php to index.php then copy the htaccess inside public folder and put it on root..

now u can access like

mysite.com/example

Please or to participate in this conversation.