What's the relative path to a user's profile? I've created a clickable block with Views and rewrote the fields with HTML like this:

&lt;a href="user"&gt; some divs... &lt;/a&gt;


Clicking the block should refer the logged-in user to his/her profile. As the code mentions, I'm using user as relative link, but a problem occurs when the user clicks the link when he/she is already visiting his/her profile: the link is then turned into mysite/user/user instead of mysite/user.

Using /user doesn't work either, because it redirects the user to localhost/user instead of localhost/mysite/user.

What's the correct way to construct a path that takes into account either being relative or the $base_path?
There is no, and can not be always correct relative path.

Relative path is relative, and there is no infinite amount of paths to user profile, to be in the same relation with each and every path in your system. There cannot be. What you need is to properly generate an absolute path instead. 

So instead of the code you are using, use Drupal's built-in link generator, l():

&lt;?php print l('some divs', 'user'); ?&gt;


or, if above is not feasible, url():

&lt;a href="&lt;?php print url('user'); ?&gt;"&gt; some divs... &lt;/a&gt;