5

For code simplicity, some of my URLs in my website might contain a ./

For example:

www.example.com/./something

The ./ is automatically stripped-out by the browser, and the resulting URL is:

www.example.com/something

My question is: could such URLs cause any trouble? Will search engines be able to correctly resolve these URLs?

3

No they will not cause any issues (nor do you need to do any kind of redirect). RFC 3986 (the official URI spec) specifies a "Reference Resolution" section which states any path segments (between slashes) containing only dots should be removed. Single dots are removed entirely while double dots essentially remove the previous directory from the URL.

Also note that no file system in popular use (Windows/Mac/Linux) allows a filename composed of just dots so a URL containing /./ doesn't really make sense.

In short, when any user agent (browser or search engine) sees a URL containing a single dot it won't ever request that URL, it will request the "proper" one.

  • +1 for the 'nor do you need to do any kind of redirect'. – William Edwards Sep 20 '14 at 13:59
1

Ideally you will have a rewrite rule that will strip it out by doing a permanent redirect (301). That way, These URLs will never be resolved, only the correct one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.