Remove URL Trailing Slash

URLs such as the following are both working

However they’re recognized as different addresses in search engine. to make your website more seo friendly it’s better to make the address unique. Here’re the rules you can add to .htaccess or web.config

If you’re using linux server and .htaccess is supported, you can add the following code to remove url trailing slash.

#remove trailing slashes
RewriteCond %{HTTP_HOST} !^\.yourdomain\.com$ [NC]
RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L]

If you’re using IIS web server, you have to configure in web.config by adding following rules.

 <rule name="Remove trailing slash" stopProcessing="true">
  <match url="(.*)/$" />
    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
  <action type="Redirect" redirectType="Permanent" url="{R:1}" />


- has written 121 posts.

Leave a Reply

You must be logged in to post a comment.