How To Remove index.php From Permalink In WordPress in 2021

Last updated on May 8th, 2022 at 11:26 am

After successfully migrating the WordPress site into some other host, the initial matter you desire to do is input Permalinks configurations and then eliminate index.php in permalink from WordPress.

Unfortunately, possessing index.php in permalink usually may contribute to 404 missing error page, interrupting user-friendly URLs.

As you indeed imported the database, then there exists a fantastic possibility which you will find  index.php by now making itself in the URL structure. If You Would like to eliminate index.php in Your permalink, Here is what you could perform:

Eliminating  index.php By WordPress Permalink

There are three steps to complete the process. So these are as follows:

Steps 1 # Check mod_rewrite is On in Your Server

In the beginning, you sign into to own hosting site and be sure that your’mod_rewrite’ is permitted. Then, whether this module is active in your server, you are going to be in a position to make an info file and check yourself.

Must Read: Read our detailed guide on Hostinger Hosting. 

In C-Panel, Mod_Rewrite has also been compiled with Apache with the default option. E.g.

[email protected] [~]# httpd -l|grep rewrite

In the event you would like to check if mod_rewrite is enabled on the host, then start up your site root directory. Now make a php file and name it mod_rewrite.php


Insert the following code inside this file.

<?php echo “Mod_rewrite is activated!”; ?>

Then generate a .htaccess file and then rename the original .htaccess file to .htaccess_1 if you’ve got it.


Insert the subsequent code in your .htaccess file.

RewriteEngine On
RewriteRule ^.*$ mod_rewrite.php


Put in your site. If you find a message like Mod_rewrite is activated, then it’s allowed in your server. If you discover whatever else as mod_rewrite is disabled, then be sure to delete the .htaccess file you generated sooner and rename the original file into .htaccess.


Steps 2 # Establish the Permalink Composition

You have to sign in to your admin dashboard and select the Setting -> and Choose Permalinks and then select the option Custom Structure and enter the /%postname%. Click save changes.


Step 3 # Modify the .htaccess Document

Now you have to log in to your website hosting  account, open the file manager, and start up the .htaccess file found within the main directory of the website folder (I am using cPanel).

file manager

Only copy the subsequent code and then paste it in your .htaccess file.

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} ! -f
RewriteCond %{REQUEST_FILENAME} ! -d
RewriteRule . /index.php [L]

# END WordPress

This is going to be sufficient to eliminate the index.php form permalink in the WordPress website.  

Read Also: Read our detailed guide on GeneratePress Theme.

Additional known Problems Which May Happen

Sometimes steps explained above won’t provide you with some results. But on specific servers using higher security, it can show up that the mod_security is obstructing your settings, so the index.php continues to be in your URL structure. To resolve this issue, you required to incorporating the below part of the code in your .htaccess file.

<IfModule mod_security.c>
SecFilterEngine Off

Read Also: Read our detailed guide on SEMrush SEO Tools.

Final  Words

An additional factor, check out a config document for Apache that can additionally reevaluate your .htaccess directives. Start looking to get Ubuntu default/etc/apache2/apache2.conf file and modify the entry for/and /var/www from AllowOverride None to AllowOverride All.

Then, restart the apache machine, and it is going to work out this matter too.

Allow me to understand the following, removing index.php from the permalink. If you confront every additional issue inquire, I will probably be pleased to aid and remember sharing this informative article with you.

Read Also

Leave a comment