0

I have installed WordPress multisite in sub-directory abc.com/en/. I want to remove the trailing slash for SEO purposes. So pages like abc.com/en/xxx/ will be 301 redirected to abc.com/en/xxx without a trailing slash.

After checking many resources (I am using Nginx), I found the code below to be working for all pages except the multisite homepage abc.com/en/. WordPress always 301 redirects abc.com/en to abc.com/en/ with a trailing slash, so it will cause a redirect loop.

if (!-d $request_filename) {
   rewrite ^/(.*)/$ /$1 permanent; 
}

So how can I remove the trailing slash for the en/ too? Many thanks in advance!

Booboo
  • 38,656
  • 3
  • 37
  • 60
4440
  • 1
  • 1

1 Answers1

0

add this line to functions.php

This this line you can fix redirect from domain.com/page to domain.com/page/ with trail slash

remove_filter('template_redirect', 'redirect_canonical');

Please don't forget clear cache or test on clean browser

utsav tilava
  • 156
  • 1
  • 12