For example, for www.example.com/foo/dosomething/, I have such a htaccess document:
RewriteEngine On
RewriteRule ^dosomething/$ myfile.php [L]
This htaccess file is inside my foo directory, which actually exists. But then I realised that, users who type the url in might forget the trailing forward slash, so they might type in this: www.example.com/foo/dosomething, and then he/she will get a 404. I don’t want that, so I wrote this instead:
RewriteRule ^dosomething/$ myfile.php [L]
But then I remembered that this isn’t SEO friendly, as two ‘web pages’ have the exact same content. So what I want now, is if the url doesn’t have a trailing forward slash at the end, for the htaccess to redirect from, for example: www.example.com/foo/dosomething to www.example.com/foo/dosomething/?
Try:
Before your
myfile.phprule. The 301 redirect will ensure that search engine indexing will equate the 2 URLs.