外部链接将域添加到链接前面,即使使用http://

时间:2022-02-03 07:25:10

Problem: External links have our domain name to the front of the link.

问题:外部链接将我们的域名放在链接的前面。

In database the following string is stored: To learn more about Rich Habits <a href=”http://www.externaldomain.com”>click here.</a>

在数据库中存储以下字符串:要了解有关Rich Habits的更多信息,请单击此处

In our PHP File we echo the string as such: </p><?php echo Author::getAuthorBio( $post->author1 ) ?></p>

在我们的PHP文件中,我们回显字符串: author1)?>

The resulting HTML from a browser is as such: <p>To learn more about Rich Habits <a href=”http://www.externaldomain.com”>click here.</a></p>

来自浏览器的结果HTML是这样的:

要了解有关Rich Habits的更多信息,请点击此处。

But, when clicking on link, the url is: mydomain.com/”http://www.externaldomain.com

但是,点击链接时,网址为:mydomain.com/"http://www.externaldomain.com“

How do I make link correct?

如何使链接正确?

2 个解决方案

#1


4  

You are trying to quote the value of the attribute with instead of ". The is not a valid character for quoting attributes in HTML, so it is being treated as part of the URL.

您试图使用“而不是”来引用属性的值。“不是用于引用HTML中的属性的有效字符,因此它被视为URL的一部分。

Since ”http:// is not a valid URL scheme, it is being treated as a relative URL.

由于“http://不是有效的URL方案,因此它被视为相对URL。

Replace the with ".

替换“与”。

Your problem is most likely caused by writing your HTML in something other than a text editor. Word processors have a habit of replacing straight quotes with typographic quotes. This is mistake when dealing with code instead of English.

您的问题很可能是由于在文本编辑器以外的其他地方编写HTML。字处理器习惯用印刷引号替换直引号。处理代码而不是英语时,这是错误的。

#2


1  

Your around the href attribute are not double quotes. They are special characters. Replace them with " and it'll fix it.

你的“href属性周围不是双引号。他们是特殊人物。用“替换它们”并且它将修复它。

#1


4  

You are trying to quote the value of the attribute with instead of ". The is not a valid character for quoting attributes in HTML, so it is being treated as part of the URL.

您试图使用“而不是”来引用属性的值。“不是用于引用HTML中的属性的有效字符,因此它被视为URL的一部分。

Since ”http:// is not a valid URL scheme, it is being treated as a relative URL.

由于“http://不是有效的URL方案,因此它被视为相对URL。

Replace the with ".

替换“与”。

Your problem is most likely caused by writing your HTML in something other than a text editor. Word processors have a habit of replacing straight quotes with typographic quotes. This is mistake when dealing with code instead of English.

您的问题很可能是由于在文本编辑器以外的其他地方编写HTML。字处理器习惯用印刷引号替换直引号。处理代码而不是英语时,这是错误的。

#2


1  

Your around the href attribute are not double quotes. They are special characters. Replace them with " and it'll fix it.

你的“href属性周围不是双引号。他们是特殊人物。用“替换它们”并且它将修复它。