How to remove index.php from url using .htaccess?

by percy_bauch , in category: SEO , 7 months ago

How to remove index.php from url using .htaccess?

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

1 answer


by zion , 7 months ago


To remove index.php from the URL using .htaccess, you can add the following code to your .htaccess file:

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

Make sure you have mod_rewrite enabled in your Apache configuration. Once you have added the code, save the .htaccess file and upload it to the root directory of your website.

This code will check if the requested file or directory exists, and if not, it will redirect the request to index.php with the requested URI as a parameter. This will hide the index.php from the URL.