logo

How to remove trailing slash from URL Drupal 10

30
October

How to remove trailing slash from URL Drupal 10
By: Anonymous | Published On: Mon, 10/30/2023 - 16:26

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.

Need Help ?