a href only will send me to subdirecteries and not

2019-07-31 18:37发布

问题:

all these links send me to a subdirectery of my site but i cant get them to send me to places like mysite.com, google.com or url.com.

<div id="header">
            <div id="loggedoutmainnav">
                <ul>
                    <li><a href ="<?php echo $_SERVER['SERVER_NAME']; ?>"><?php echo $_SERVER['SERVER_NAME']; ?></a></li>
                    <li><a href ="www.google.com">Google</a></li>
                    <li><a href ="url.com">Url</a> </li>
                    <li><a href ="#">Plans & Pricing</a></li>
                    <li><a href="#">Log in</a></li>
                </ul>
            </div>
        </div>

so if i click on the google button, it will send me to mysite.com/www.google.com

回答1:

<a href ="http://www.google.com">Google</a>

This should work. You need to add "http://" because it's an external link



回答2:

You need to add http:// before the URL for external sites.