Remove index.php and redirect old URLs to the correct pages without using htaccess
In this WordPress tutorial, we will remove ‘index.php’ from the URLs and also redirect all the links to the new ones. Basically, if you had shared your URLs with ‘index.php’ in them, after changing it, they will be redirected to the original URL even if anyone goes to the ‘index.php’ link. We will not be using .htaccess but some codes in the theme functions file.
To do that, log in to the WordPress dashboard and go to the ‘Settings’ tab, then click on ‘Permalinks’. Select ‘Post name’ or alternatively, you can create a custom structure that suits your preferences and save the changes. This will remove the ‘index.php’ from the URL.
Now, to ensure that the old links still redirect visitors to the correct pages, simply copy the code provided below and paste it into the theme functions. By following these simple steps, you can ensure that your website’s URLs are clean, concise, and free of any unnecessary clutter.
Thank you.
Disable Auto-Update Email Notifications and Block Updates for Plugins, WP Core, and Themes
How to increase upload file size limit in WordPress cPanel
How to Create a Coming Soon Page Without Plugins in WordPress