WordPress converting ../url to http://../url

If you can access your page at http://example/wordpress/page2, then use the following code to output a link to your page, no matter what your site url is:

echo site_url('/page2/');

This appends the /page2/ to your website’s url (which is http://example/wordpress/ ), which would be :

http://example/wordpress/page2/