WordPress Permalink Structure

Remove index.php from permalink in WordPress

After WordPress migration to another server, which don’t necessarily have to have the same settings as the one you are migrating from, there is a chance of having “index.php” added to your URL. This can often lead to 404 missing page error and it disrupts friendly URL’s. Learn how to remove index.php from permalink in WordPress.

After successful migration of your WordPress site to another server the first thing you probably would wanna to do is to enter the Permalinks settings and check your desired option for permalinks, which in most cases is “Post name” and to save that setting into the database. But since you probably imported database chances are that you are going to see the “index.php” already created itself into the URL structure. If you want to remove index.php from permalink in WordPress here is what you might try to do:

1. Find out if “mod_rewrite” is enabled on your server

If you don’t have direct info from your hosting provider if this module is active on your server you can create info file and check for yourself. Learn how to create PHP info file in this post.

2. Set the permalink structure

Go to Dashboard > Settings > Permalinks and choose “Custom Structure” option and enter in the field: /%postname%/ and click on Save Changes button.

3. Edit your .htaccess file

Copy the following directive into your .htaccess file which is located in the root of your website folder:

# 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]
</IfModule>
# END WordPress

This should be enough to remove the index.php from the URL structure.

Learn more about Permalinks in WordPress on the official WordPress Codex page.

0 comments

Leave a Reply