Reputation: 1792
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.
Upvotes: 2
Views: 2204
Reputation: 51
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.
Upvotes: 1