WP Rocket Removes End of URLs slash! What’s the solution ?!

WP Rocket Removes End of URLs slash! What’s the solution ?!

A few days ago, one of my dear compatriots called me and talked about a problem with the MihanWP. The problem is WordPress URLs work even without a slash at the end of the URL that they asked to explain.

For example, right now, you can also view the MihanPanel page as https://ertano.com/mihanpanel. Now the same page can be seen with https://ertano.com/mihanpanel/. We need to have a redirect here from https://ertano.com/mihanpanel to https://ertano.com/mihanpanel/ but redirect does not happen.

Relate this problem to WP Rocket

When we disable WP Rocket from our website, the problem is solved, and this issue makes sure that the problem is WP Rocket.

Do we really need to solve this problem

There is no need to solve this problem. Because your URLs will be announced to Google bots by Google in the same way that your website and other websites link to your website.

Now Google does not have any URL from our website like https://ertano.com/mihanpanel, so this will prevent this page from being recognized as a duplicate content page by Google.

So we do not need to solve this problem.

How to solve the problem

If this issue is on your nerves, it is better to solve it. Like a friend who told me I get better Google visits when changing my website header color to red. 🙂 So, with a beautiful smile, I asked him to redden the header of his website to have more visits. : D

Method 1: Use the plugin

All you need is the Enforce Trailing Slash on URLs plugin and install it on your website. Just as easily! The problem will be solved without the need for any settings. This plugin is working out of the box.

Method 2: Solve the problem without having to install the plugin

In the second method, enter your hosting file manager and edit the .htaccess file. Then add the following code to this file, and the problem will be solved forever.

# Force trailing slash by mihanwp.com
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_METHOD} GET
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteCond %{REQUEST_FILENAME} !\.(gif|jpg|png|jpeg|css|xml|txt|js|php|scss|webp|mp3|avi|wav|mp4|mov)$ [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1/ [L,R=301]

Just as easily! Good luck.

Is there any particular point that would complete this article?

  1. U327 April 16, 2023

    If i want to redirect it without End of URLs slash, What should I do?

    Example site. com/post-url/ to site. com/post-url