30
October
You can remove trailing slashes from URLs using the .htaccess
file and mod_rewrite
Add the following code to your .htaccess
file to Remove Trailing slashes from all URL of website.
RewriteRule ^(.*)\/(\?.*)?$ $1$2 [R=301,L]
This code will remove the trailing slash from URLs and issue a 301 redirect, so if someone accesses a URL with a trailing slash, they will be redirected to the same URL without the trailing slash.
Make sure you have the mod_rewrite module enabled in your Apache configuration.
© 2023.ZedAngle. All Rights Reserved.