logo
Tutorial

Remove index.php from URL using htaccess

Written by Abhilash SahooUpdated on February 28, 20231 min read

Many PHP developers find it difficult to remove index.php from URL. The best way is to use  .htaccess file in your root directory.

mod_rewrite must be enable with php and this will work for the php version higher than 5.2.6

RewriteEngine On  RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php?/$1 [L]

PHP version less than 5.2.6 try this

RewriteEngine On  RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php/$1 [L]

Save the .htaccess file. We hope the above changes to the htaccess file can help you to remove the index.php from your URL. You can use the above method for any CMS like Joomla, Magento or WordPress.


If you need any help on this then feel free to contact us. Our experienced developers will help you fix the issue.

Share the Article

Abhilash Sahoo

Abhilash Sahoo

Abhilash Sahoo, with over 14 years of experience, is a Certified Full Stack Developer and Application Development Expert. As the Founder & CEO of Infyways Solutions, he leads a team specializing in end-to-end web and application development solutions. Under his guidance, Infyways has become a trusted name in delivering scalable, innovative, and custom-tailored applications that meet the unique needs of businesses across industries