0

I am printing my custom URL's in footer which I am getting from database, Some thing like this Assume this contains www.google.com link.

 <li><a href="<?php echo $links['link_url']?>"><?php echo $links['title'] ?></a></li>

When I click on this link at footer, it redirecting with my current page URL

www.mydomainname.com/www.google.com

How can I avoid attaching my current domain name to it? It should be redirect to "www.google.com"

1 Answer 1

4

The href attribute specifies the URL of the page you're linking to. If you don't provide a protocol to the URL it will assume it's a relative URL and therefore append it to your current path / URL. If you specify a protocol (such as http:// or https://) you'll be taking to the absolute URL. You want to link to use absolute URLs and not relative ones.

Add website url with protocol in your database.

e.g. http://www.google.com

So,it will redirect to google page.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.