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
-
I'm struggling to understand (and fix) why I'm getting a 404 error. The URL includes this "%5Bnull%20id=43484%5D" but I cannot find that anywhere in the referring URL. Does anyone know why please? Thanks
Can you help with how to fix this 404 error please? It appears that I have a redirect from one page to the other, although the referring page URL works, but it appears to be linking to another URL with this code at the end of the the URL - %5Bnull%20id=43484%5D that I'm struggling to find and fix. Thanks
Technical SEO | | Nichole.wynter20200 -
Site scraped over 400,000 urls
Our business is heavily dependent on SEO traffic from long tail search. We have over 400,000 pieces of content, all of which we found scraped and published by another site based out of Hong Kong (we're in the US). Google has a process for DMCA takedown, but doing so would be beyond tedious for such a large set of urls. The scraped content is outranking us in many searches and we've noticed a drastic decrease in organic traffic, likely from a duplicate content penalty. Has anyone dealt with an issue like this? I can't seem to find much help online.
Technical SEO | | Kibin0 -
Language Specific Characters in URLs for
Hi People, would really appreciate your advice as we are debating best practice and advice seems very subjective depending if we are talking to our dev or SEO team. We are developing a website aimed at the South American market with content entirely in Spanish.  This is our first international site so our experience is limited.  Should we be using Spanish characters (such as www.xyz.com/contáctanos) in URLs or should we use ASCII character replacements? What are the pros and cons for SEO and usability? Would really be great to get advice from the Moz community and make me look good at the same time as it was my suggestion  🙂 Nick
Technical SEO | | nickspiteri0 -
Category URL Pagination where URLs don't change between pages
Hello, I am working on an e-commerce site where there are categories with multiple pages. In order to avoid pagination issues I was thinking of using rel=next and rel=prev and cannonical tags. I noticed a site where the URL doesn't change between pages, so whether you're on page 1,2, or 3 of the same category, the URL doesn't change. Would this be a cleaner way of dealing with pagination?
Technical SEO | | whiteonlySEO0 -
Friendly URL
Can be Friendly URL installed on a custom made jobsite using mod rewrite / apache without any big interference to the system itself? Thank you.
Technical SEO | | tomaz770 -
Order of keyword usage in URL
Hi, I have been wondering for a few weeks if the order of keyword usage for a long tail keyword made a difference. Today I ran an on-page report here for a new page which is a review of a product. The report warned about the keyword usage in URL which made me question my knowledge about this. let's say the page is titled Razer Mouse Review my URL is www.example.com/review/razer-mouse I thought it was a bad idea to repeat the same word in a URL, that's why I categorized all my reviews under review directory and avoided using the word "review" more than once. Should I modify this url and make it www.example.com/review/razer-mouse-review Note: I see the report listed this under "moderate importance factors" and still gave the page A grade. any ideas appreciated!
Technical SEO | | Gamer070 -
Duplicate canonical URLs in WordPress
Hi everyone, I'm driving myself insane trying to figure this one out and am hoping someone has more technical chops than I do. Here's the situation... I'm getting duplicate canonical tags on my pages and posts, one is inside of the WordPress SEO (plugin) commented section, and the other is elsewhere in the header. I am running the latest version of WordPress 3.1.3 and the Genesis framework. After doing some testing and adding the following filters to my functions.php: <code>remove_action('wp_head', 'genesis_canonical'); remove_action('wp_head', 'rel_canonical');</code> ... what I get is this: With the plugin active + NO "remove action" - duplicate canonical tags
Technical SEO | | robertdempsey
With the plugin disabled + NO "remove action" - a single canonical tag
With the plugin disabled + A "remove action" - no canonical tag I have tried using only one of these remove_actions at a time, and then combining them both. Regardless, as long as I have the plugin active I get duplicate canonical tags. Is this a bug in the plugin, perhaps somehow enabling the canonical functionality of WordPress? Thanks for your help everyone. Robert Dempsey0 -
Page Titles where URL customization is limited
Hi all, I'm working for a new company which has several websites built on the Miva Merchant 5.5 platform. I'm new to SEO and trying to improve one specific category of products. With Miva the URL structure is set to: "category/" or "product/". I would have liked to have the ability to create URLs like "bike/beach-cruisers/mens-red-hawaiian.html". Since I cannot do that I'm trying to determine the best product name and page titles. Currently all of our titles have the word "bike". So when a category page is displayed, which shows over 100 products I get flagged in my campaign for over using the keyword "bike". However, if I take the work "bike" out of the page title I'm concerned that it would hurt us in the SERPs. Another factor that I'm getting flagged for on my campaign is the fact that our navigation uses the same key words repeatedly in each link. I'm not sure if it's really hurting us or not. Below is an example. I'm looking for some input on recommendations for product names and page titles. Below are some examples of what I'm working with. Any input or suggestions are greatly appreciated. Menu Sample: Bikes-Street-Blue-Mens Bikes-Street-Blue-Womens Bikes-Street-Blue-Kids Bikes-Street-Orange-Mens Bikes-Street-Orange-Womens Bikes-Street-Orange-Kids Bikes-Beach-Cruiser-Blue-Mens Bikes-Beach-Cruiser-Blue-Womens Bikes-Beach-Cruiser-Blue-Kids Bikes-Beach-Cruiser-Orange-Mens Bikes-Beach-Cruiser-Orange-Womens Bikes-Beach-Cruiser-Orange-Kids Current Page Titles/Name: Mens Bike Street Blue | XYZ Bike Mfg. - product/mens-bike-street-blue.html Mens Bike Street Orange | XYZ Bike Mfg. - product/mens-bike-street-orange.html Womens Bike Street Blue | XYZ Bike Mfg. - product/womens-bike-street-blue.html Womens Bike Street Orange | XYZ Bike Mfg. - product/womens-bike-street-orange.html
Technical SEO | | Technical_Contact0