The Moz Q&A Forum

    • Forum
    • Questions
    • My Q&A
    • Users
    • Ask the Community

    Welcome to the Q&A Forum

    Browse the forum for helpful insights and fresh discussions about all things SEO.

    1. SEO and Digital Marketing Q&A Forum
    2. Categories
    3. Technical SEO Issues
    4. Making URLs automatically clickable

    Making URLs automatically clickable

    Technical SEO Issues
    2 2 81
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as question
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • rasmusbang
      rasmusbang last edited by

      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>

      1 Reply Last reply Reply Quote 0
      • irvingw
        irvingw last edited by

        I would post this on a PHP coding forum for a better response.

        1 Reply Last reply Reply Quote 1
        • 1 / 1
        • First post
          Last post
        • Should I canonicalize URLs with no query params even though query params are always automatically appended?
          LeahH
          LeahH
          0
          3
          24

        • Absolute URL or Relative URL in my sitemap?
          brianvest
          brianvest
          0
          3
          9.6k

        • How could you make a URL/Breadcrumb structure appear different in Google than when you click into site?
          ATP
          ATP
          0
          4
          994

        • Friendly URLS (SEO urls)
          irvingw
          irvingw
          0
          5
          217

        • Updating content on URL or new URL
          RuudHeijnen
          RuudHeijnen
          0
          7
          273

        • How to find original URLS after Hosting Company added canonical URLs, URL rewrites and duplicate content.
          Nobody1560986989723
          Nobody1560986989723
          0
          2
          366

        • Crawl reveals hundreds of urls with multiple urls in the url string
          irvingw
          irvingw
          0
          5
          455

        • How to make multiple url redirection using global.asax in IIS 6?
          lavellester
          lavellester
          0
          2
          2.4k

        Get started with Moz Pro!

        Unlock the power of advanced SEO tools and data-driven insights.

        Start my free trial
        Products
        • Moz Pro
        • Moz Local
        • Moz API
        • Moz Data
        • STAT
        • Product Updates
        Moz Solutions
        • SMB Solutions
        • Agency Solutions
        • Enterprise Solutions
        • Digital Marketers
        Free SEO Tools
        • Domain Authority Checker
        • Link Explorer
        • Keyword Explorer
        • Competitive Research
        • Brand Authority Checker
        • Local Citation Checker
        • MozBar Extension
        • MozCast
        Resources
        • Blog
        • SEO Learning Center
        • Help Hub
        • Beginner's Guide to SEO
        • How-to Guides
        • Moz Academy
        • API Docs
        About Moz
        • About
        • Team
        • Careers
        • Contact
        Why Moz
        • Case Studies
        • Testimonials
        Get Involved
        • Become an Affiliate
        • MozCon
        • Webinars
        • Practical Marketer Series
        • MozPod
        Connect with us

        Contact the Help team

        Join our newsletter
        Moz logo
        ยฉ 2021 - 2026 SEOMoz, Inc., a Ziff Davis company. All rights reserved. Moz is a registered trademark of SEOMoz, Inc.
        • Accessibility
        • Terms of Use
        • Privacy