Hi everyone, i'm newbie here just want to catch some knowledge here, i just wondering to know how to make link like mediafire download link, such as

is that using .htaccess editing?

thanks

Dani AI

Generated

No need to touch .htaccess for this — .htaccess is for URL rewriting/redirects, not turning pasted text into anchors. was right to suggest pattern matching; below is a compact, safe PHP helper that builds clickable links from http/https text, preserves trailing punctuation, and avoids XSS. Posting this here for and anyone else who wants the code.

<?php
function autolink($text) {
    // Split text so URL parts are captured
    $parts = preg_split('~(https?://[^\s<]+)~i', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
    foreach ($parts as $i => $part) {
        if ($i % 2 === 0) {
            // non-URL fragments: escape
            $parts[$i] = htmlspecialchars($part, ENT_QUOTES, 'UTF-8');
        } else {
            // URL fragment: trim trailing punctuation, build safe anchor
            $url = rtrim($part, ".,;:!?)]}'\"");
            $trail = substr($part, strlen($url));
            $href = htmlspecialchars($url, ENT_QUOTES, 'UTF-8');
            $label = htmlspecialchars($url, ENT_QUOTES, 'UTF-8');
            $parts[$i] = '<a href="' . $href . '" target="_blank" rel="noopener noreferrer">' . $label . '</a>' . $trail;
        }
    }
    return implode('', $parts);
}

Notes and tips:

  • The function escapes non-URL text with htmlspecialchars to prevent XSS, and escapes the href/display separately. Query strings (the ? and & parts) are handled normally.
  • Trailing punctuation like periods or closing parentheses is preserved after the link.
  • To accept scheme-less links (starting with "www.") or other protocols (ftp), expand the regex or add a second pass that prefixes "http://" to matches.
  • For stricter checks, validate with filter_var($url, FILTER_VALIDATE_URL) before converting.
  • If a CMS or template already escapes output, avoid double-escaping by running this on raw input at render time (or adapt to the platform's escaping rules).

Recommended Answers

All 2 Replies

you can do a pattern matching in strings. Whenever somebody pastes a link in your textbox. Search for http:// and replace that text with <a href="<the-link>">the-link</a>

I guess this might help...If not...send me a PM, I'll send you the PHP code.

you can do a pattern matching in strings. Whenever somebody pastes a link in your textbox. Search for http:// and replace that text with <a href="<the-link>">the-link</a>

I guess this might help...If not...send me a PM, I'll send you the PHP code.

Plz Send The Code Here So It Will Help Everyone

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.