简体   繁体   中英

External url is not working in PHP

I was wondering if anyone knew how to solve this. Im using wordpress.

I wanted to show the full url on a page. My code is like this:

<p><?php echo '<a href="'.$url.'" title="'.$work->post_title.'" target="blank">'.__($url, "").'</a>'  ?> </p>

You can see the url but when you click on it you'll get redirected to http:// Myownwebsite .com/ THE_URL

The problem is the “myownwebsite.com” part, how can I get rid of it? I've also tried

<p><?php echo '<a href="'.$url.'"> '.$url.' </a>' ?> </p>

Any help ?

PS: Adding RewriteRule ^links$ %{QUERY_STRING} [L,R=301] to .htaccess doesn't help.

I've solved it. I have to use [http://www.] for $url instead of [www] I wanted to post this earlier, but stackoverflow didn't let me edit it for 8 hours.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM