Ad

301 Redirect On New Domain Without Trailing / Slash

- 1 answer

I would like to redirect all url's from domain:

http://exampledomain.com

to new domain on specyfic address which works only without trailing slash on the end of address

http://www.newdomain.com/123-content

I tried many rules in .htaccess, but everytime it redirects to url with / on the end and it not works.

Ad

Answer

Put the following rules at .htaccess in oldsite main root :

RewriteEngine On
RewriteCond %{REQUEST_URI} ^(.*)([^/]+)/?$
RewriteRule ^    http://newdomain.com%1%2  [L,R=301]

Note: clear browser cache then test

Ad
source: stackoverflow.com
Ad