Remove index.php and redirect old URLs to the correct pages without using htaccess

Опубликовано: 05 Март 2024
на канале: Let's Learn WordPress
193
4

Download code: https://letslearnwordpress.com/wordpr...

#permalinks #wordpresstutorial #settings

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 function 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.

-----------------------------

We got A scores on GTmetrix and 90+ on Google PageSpeed Insights for heyletslearnsomething.com!

These are affiliate links, BUT WE USE THEM on our site; We do not promote anything we don't use!

WP Rocket:
https://shrsl.com/3348v

Hosting:
https://shrsl.com/33491

WordPress themes - We use "Enfold"
https://1.envato.market/c/2653046/528...