Register Login

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

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 that also existed on the MihanWP. The problem is WordPress URLs working 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://mihanwp.com/en/mihanpanel. Now the same page can be seen with https://mihanwp.com/en/mihanpanel/. We need to have a redirect here from https://mihanwp.com/en/mihanpanel to https://mihanwp.com/en/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

In fact, 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 site.

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

So we really 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 I 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.

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

In the second method, just 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.

What is your comment?