How to remove index.php from URL with .htaccess

How remove index.php from URL with .htaccess


Everyone prefers a cleaner-looking URL for their website and "index.php" might be the one thing they don't want to see in their URL. It is also important to remove unwanted text from your URL to make it look more relevant and represent the content of that particular page.

There are different ways to do so depending on different factors like the framework you are using etc. but the easiest and most used one is with .htaccess.

Removing index.php from URL:

To remove or hide index.php from the URL link, you have to put the following code in your .htaccess file.

After putting this code in your .htaccess file it will simply hide the index.php from the Website's URL.

RewriteEngine On
RewriteBase /

# Removes index.php
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$$1 [R=301,L]
RewriteRule ^(.*)index$$1 [R=301,L]

This is how your original URL looked:

But when you choose to remove index.php from this URL, it will become like this:

It is surely looking more relevant than before.

If you think I have missed out on anything in this blog and if this blog helped you, so please comments and I will surely update that with this list.

Do share this blog with your social accounts, so that your friends can also reach this list

.htaccess topics:

Best WordPress Hosting


Discount Coupons

Get a .COM for just $6.98

Secure Domain for a Mini Price

Leave a Reply

    Waiting for your comments