Forum Moderators: phranque

Message Too Old, No Replies

Bad links domain.com/" How to strip html characters?

         

bugauto

11:44 pm on May 31, 2008 (gmt 0)

10+ Year Member



There are people clicking bad links to my site. The links contain html characters in the url. Examples are below.

mydomain.com/"http://www.mydomain.com/dir/img.jpg"

some how there browser is rendering whats inside of an input text tag.

example input text tag on my site is


<input type="text" value="<a href=&quot;http://<?php echo $site_url . $site_page; ?>&quot; target=&quot;_blank&quot;><img src=&quot;http://<?php echo $site_url . $urlpath. $file; ?>&quot;</a><br><a href=&quot;http://<?php echo $site_url . $site_page; ?>&quot;><?php echo $cat_no_symbols; ?>Comments at <?php echo $site_name; ?></a><br>">

How can I use htaccess to make sure their browser does not render what's in the input tag?

jdMorgan

2:09 am on Jun 1, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can't use htaccess to fix this, you need to fix the links on your pages. If there are similarly-broken links from other sites, they can be fixed-up in .htaccess, but the links on your own site must be correct to avoid a "google-disaster."

I'm no PHP expert, but that code looks broken in several places. You might consider 'building' the entire <input> line, and then outputting all of it with a single php echo. To embed a quote in your string, escape it with a \ character, like this: \"

Jim