Making URLs automatically clickable
-
Hi all,
I have a PHP function which i use to make all links clickable. Problem is, if some one writes a link in a a-tag, the URL inside the href value is made clickable. Not good.
Can someone perhaps help me with the issue?
Function:
function makeClickableLinks($text)
{
$text = preg_replace('/<//', ' $text = preg_replace('(
)', '
', $text);
$text = preg_replace('!((https?://www.|https?://|www.)(([a-z0-9-]+.)+[a-z]{2,6})(/\S+|/)*)!ie', '"[".shortenurl("\1")."]("".(strtolower('$2'))"', $text);
$text = str_replace('( <a href',="" '<a="" $text);<br="">$text = str_replace(')" target', '" target', $text);
$text = str_replace('):" target', '" target', $text);
$text = str_replace(')..." target', '" target', $text);
$text = str_replace(').." target', '" target', $text);
$text = str_replace(')." target', '" target', $text);
return $text;
}</a><a href',="" '<a="" $text);<br="">Pleeeeease heeelp Can't fix it on my own - been at it for ages.
-Rasmus</a>
-
I would post this on a PHP coding forum for a better response.
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
Category url with resultsperpage loop
Hi there, We upgraded our webshop last weekend and our moz crawl on monday found a lot of errors we are trying to fix. I am having some communication problems with our webmaster so I need a little help. We have extremely long category pages url, does anyone have a guess which kind of mistake our webmaster could make:
Technical SEO | | isabelledylag
https://site-name.pl/category-name?page=3?resultsPerPage=53?resultsPerPage=53 .... And it keeps on repeating the string ?resultsPerPage=53 exactly 451 times as if there was some kind of loop. Thanks in advance for any kind of hint 🙂
Kind regards,
Isabelle0 -
Tool to Generate All the URLs on a Domain
Hi all, I've been using xml-sitemaps.com for a while to generate a list of all the URLs that exist on a domain. However, this tool only works for websites with under 500 URLs on a domain. The paid tool doesn't offer what we are looking for either. I'm hoping someone can help with a recommendation. We're looking for a tool that can: Crawl, and list, all the indexed URLs on a domain, including .pdf and .doc files (ideally in a .xls or .txt file) Crawl multiple domains with unlimited URLs (we have 5 websites with 500+ URLs on them) Seems pretty simple, but we haven't been able to find something that isn't tailored toward management of a single domain or that can crawl a huge volume of content.
Technical SEO | | timfrick0 -
What might make Bing.bot find a URL that looks like this on our site?
I have been doing something Richard Baxter recently suggested and reviewing our server logs. I have found an oddity that hopefully some of you smart Mozzers can help me figure out. Here is the line from the server log (there are many more like this): 157.55.32.166 - - [04/Mar/2013:08:00:59 -0800] "GET /StoreFront/category/www.ccisolutions.com/StoreFront/category/shure-se-earphones HTTP/1.1" 200 94133 "-" "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)" "-" See how the www.ccisolutions.com appears after /StoreFront/category/ ? We used to see weird URLs reported in GWT that looked like this, but ever since we fixed our canonical tags to be absolute instead of relative URLs, they no longer appeared in our Webmaster Tools reports. However, it seems there is still a problem. Where/how could Bingbot be seeing URLs configured this way? Could it be a server issue, or is it most likely a data problem? Thanks in advance! Dana P.S. Could this be resulting from our massive use of relative URLs all over the site?
Technical SEO | | danatanseo0 -
Determine the best URL structure
Hi guys, I'm working my way through a URL restructure at the moment and I've several ideas about the best way to do it. However, it would be good to get some views on this. At the moment I'm working on a property website - http://bit.ly/N7eew7 As you can quickly see, the URL structure of the site needs a lot of work. Similar websites - http://bit.ly/WXH5WG http://bit.ly/Q3UiLC One of the sites has http://www.domain.ie/property-to-let/location/ And the other has http://www.domain.ie/rentals/location/property-to-let/ I could do with some guidance about the best steps to take with this. I've a few ideas myself but this is a massive project. Cheers, Mark
Technical SEO | | MarkScully0 -
Special characters in URL
Hi There, We're in the process of changing our URL structure to be more SEO friendly. Right now I'm struggling to find a good way to handle slashes that are part of a targeted keyword. For example, if I have a product page and my product title is "1/2 ct Diamond Earrings in 14K Gold" which of the following URLs is the right way to go if I'm targeting the product title as the search keyword? example.com/jewelry/1-2-ct-diamond-earrings-in-14k-gold example.com/jewelry/12-ct-diamond-earrings-in-14k-gold example.com/jewelry/1_2-ct-diamond-earrings-in-14k-gold example.com/jewelry/1%2F2-ct-diamond-earrings-in-14k-gold Thanks!
Technical SEO | | Richline_Digital0 -
URL Structure: When to insert keywords?
I read the SEOmoz beginers guide and it said that it's beneficial to place keywords in the URL as long as you don't overdo it. However, this seems awkward for common pages, such as "Home", "About", "Contact" etc.... I've currently targeted a specific keyword for each page on my site, as follows: Home: "Green Screen" Work: "Greenscreen" About: "Event Photography" Pricing: "Green Screen Photography" Should I rename the URLs as: Home: ...com/green-screen-home.html Work: ...com/greenscreen-work.html About:...com/about-event-photography.html Pricing:...com/green-screen-photography-pricing.html
Technical SEO | | pharcydeabc0 -
Www or not www base url
Here is the situation. Developer custom coded a magento commerce shop for a seo client and is having problems adding www to the URL without breaking the site. They wont be able to get this completed until a couple months down the road. We are starting monthly SEO this June. Most directories and websites link to the www version of a site not the non www. What should I expect since we are ranking for the non-www and linking to the www version. In web master tools i'm telling google to display the URL as www.
Technical SEO | | waqid0 -
Variables in URLS?
How much do variables in URLs hurt indexing of that page? I'm worried that with this huge string of variables that the pages won't get indexed. Here's what I think we should have: http://adomainname.com/New/Local/State/City/Make/Model/ Here's the current URL:http://adomainname.com/New/Local/MN/Bayport/Jeep/Liberty?curPage=1&pageResultSize=50&orderDir=DESC&orderBy=ModifiedDate&conditionId=1&makeId=7&modelId=141&stateProvinceName=Minnesota&mc=1
Technical SEO | | CFSSEO0