Let’s say you use WordPress.
You may know, for SEO purposes, it’s better to redirect a user visiting:
You should be enforcing small URLs to all users, for SEO.
Note: there is a high likelihood that this script will give errors on very big web sites and old web sites (asking for a Big Letter CSS file, and receving a small one). Try to use it on new web sites, where you can instantly see if anything goes wrong.
You also have the option of implementing rel=canonical, which give you 70-80% of the results of the current solution