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

by percy_bauch , in category: SEO , 6 months ago

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

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

1 answer

Member

by zion , 6 months ago

@percy_bauch 

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

1
2
3
4
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.