Wordpress remove php from url

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?

Wordpress remove php from url

Armali

16.8k13 gold badges54 silver badges157 bronze badges

asked Sep 17, 2015 at 11:20

Wordpress remove php from url

9

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

answered Sep 17, 2015 at 11:57

1

Not the answer you're looking for? Browse other questions tagged php mysql wordpress apache .htaccess or ask your own question.

  • Hello,

    I have WordPress 5.4.1 installed on my server.
    The URL of the page is http://192.168.61.7/wordpress/index.php/page-name
    I changed the permalink structure to http://192.168.61.7/wordpress/page-name and updated the .htaccess folder with the following code:
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /wordpress/
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /wordpress/index.php [L]
    </IfModule>
    and im still not able to get rid of the index.php in the URL

    • This topic was modified 2 years, 3 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Developing with WordPress topic

  • By default, Apache adds .php to URL for PHP files. Here’s how to remove .php from URL in Apache. You can use these steps to remove .php from URL in WordPress, Magento, Drupal, Joomla and other CMS systems. You can also use it to remove index.php from URLs.

    Remove .php extension from URL

    Before proceeding further, you need to enable mod_rewrite in Apache web server. Here are the steps to enable mod_rewrite (.htaccess) in Apache web server.

    1. Open htaccess file

    Open terminal and run the following command to open .htaccess file. Please change the file path to .htaccess file as per your requirement.

    $ sudo vi /var/www/html/.htaccess

    2. Remove .php extension from URL

    Add the following lines to redirect all URLs with .php extension to URLs without file extension.

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.php -f
    RewriteRule ^(.*)$ $1.php [NC,L] 

    In the above code, the first line checks that the request is a URL and not a directory. The second line redirect matching URLs with .php extension to those without file extension. The last line redirects matching requests to URLs without php file extension.

    Similarly, you may also add the following code to remove .html extension from URL.

    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME}\.html -f 
    RewriteRule ^(.*)$ $1.html [NC,L]

    3. Restart Apache web server

    Restart Apache server with following command

    $ sudo systemctl restart httpd

    Ubiq makes it easy to visualize data in minutes, and monitor in real-time dashboards. Try it Today!

    • About Author

    Wordpress remove php from url

    How do I remove php extension from WordPress URL?

    How to Remove ..
    Open htaccess file. Open terminal and run the following command to open . htaccess file. ... .
    Remove . php extension from URL. ... .
    Restart Apache web server. Restart Apache server with following command $ sudo systemctl restart httpd..

    Why does my URL say index php?

    The most common reason for index. php appearing is improper permalink structure. Therefore first check if the structure is set properly. To check it, navigate to Settings -> Permalinks.
    Once you find the item that has the permalink you want to use, you need to permanently delete it or change its permalink. If you'll never need the item again: Delete it by clicking Trash or Move to Trash. Typically this action frees up the permalink immediately. If it doesn't, go to Trash and hit Permanently Delete.

    How do I remove a site index?

    htaccess file for your website..
    Open . htaccess file. Open terminal and run the following commands to open . ... .
    Remove index. php from URL. Add the following lines in . ... .
    Restart Apache web server. Restart Apache server to apply changes $ sudo systemctl restart httpd..