1

I am forcing my website to add trailing slash, but it is showing error - Too many Redirects.

I have used these two methods to add traling slash and both gave error.

function add_slash( $string, $type ){
    $string = trailingslashit($string);
    return $string;
}
add_filter('user_trailingslashit', 'add_slash', 70, 2);

RewriteCond %{REQUEST_URI} /+[^\.]+$ 
RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]

How can I avoid this error. Also the website has plugin called Custom Permalink to simplify custom post type URL, I have checked the settings of the plugin, there is no option for enforcing trailing slash.

Please correct me if I am doing something wrong.

Mohammad Umar
  • 1,722
  • 1
  • 14
  • 20

1 Answers1

1

Go to the “Settings -> Permalinks -> Choose Custom Structure option ” The “Custom Structure” field ends with a slash, so all other WordPress URLs will have the trailing slash. Or you can check attached media for more details. enter image description here