Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: To remove index.php from Wordpress URL(Plesk)  (Read 11780 times)

0 Members and 1 Guest are viewing this topic.

rinop

  • Guest
To remove index.php from Wordpress URL(Plesk)
« on: June 07, 2018, 06:20:24 am »
After WordPress migration to another server, there is a chance of having “index.php” added to your URL. This can often lead to 404 missing page error.

Follow the below steps to remove index.php from permalink in WordPress :

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


mod_rewrite is an Apache module that allows for server-side manipulation of requested URLs. mod_rewrite is most commonly used to transform ugly, cryptic URLs into what are known as “friendly URLs” or “clean URLs.

You can test if mod_rewrite is enabled/working in a number of ways. One of the simplest methods is to view the output from PHP’s phpinfo function.

2. Set the permalink structure :

Go to Plesk 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 document  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 will be enough to remove the index.php from the URL structure.

However, on some servers with mod_security may block your settings thus index.php still remains in the URL structure. Add the following code in your .htaccess file above the rules we added in the previous step :

<IfModule mod_security.c>
SecFilterEngine Off
</IfModule>



Please note:  Apache can also override your .htaccess directives. Look under Apache configuration file and change the entry for / and /var/www from AllowOverride None to AllowOverride All. Then restart Apache server and thus it will remove index.php from URL.