How to remove index.php from WordPress site URL

28,074

Go to your WP-ADMIN-->Settings-->Permalink and use the permalink structure change there, if it generate any .htaccess file copy the content and update your .htaccess file.

Or Check if your hosting mod_rewrite is enable by creating a file phpinfo.php with content,

<?php phpinfo();?>

Upload this file and browse via Browser. So you know which modules are enabled. You need mod_rewrite enable to remove index.php from URL.

More details Check this link

Share:
28,074
Rahul Ahirwar
Author by

Rahul Ahirwar

Updated on July 07, 2022

Comments

  • Rahul Ahirwar
    Rahul Ahirwar almost 2 years

    I have a problem with index.php in my WordPress website. This problem is arriving since I have changed and migrated my WordPress database from WordPress to mydatabase. I have also changed my table prefix name.

    Now problem is that, I am unable to see my pages and posts without index.php.

    http://example.com/index.php/postname/

    I have tried the following solutions:

    1. Change permalinks setting (nothing changed).

    2. Change rewrite module with .htaccess file (nothing changed).

    3. Enable rewrite module in my apache2 server (nothing happened).

    4. Deleted value of rewrite_module of wp_options table for cache purpose (nothing happened).

    5. If i set permalink for %postname%

    e. g. http://example.com/postname/

    Then i get 404 error.

    My .htaccess code is:

    # 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
    

    Please anybody provide me correct solution. How to get rid of index.php?

  • Rahul Ahirwar
    Rahul Ahirwar over 8 years
    when i see phpinfo it is already enable in Loaded Modules of apache2handler configuration section.