1

I have a column containing the html for page_content.

With my limited knowledge on SQL I can only find external links or links that have rel="nofollow" in them.

But I need help to find the links which are external and doesn't have the rel="nofollow" attribute and possible add it.

Lorem ipsum <a href="http://own-domain.com">dolor</a> sit amet, consectetur adipiscing elit.     
Cras mi lacus, <a href="http://external-domain.com">**mattis**</a> vel rutrum lobortis, pharetra in elit. Praesent consequat <a rel="nofollow" href="http://own-domain.com">condimentum</a> diam ut sodales.

I want to add nofollow attribute to mattis , taking care not to add it to own-domain or adding nofollow twice on condimentum.

UPDATE : Note, that I need to do this on the database of a custom CMS like wordpress. My pages are rendered in PHP. I can modify the source while content load. But I prefer to do this in the database layer to make it permanent.

Debajyoti Das
  • 2,038
  • 4
  • 34
  • 66

1 Answers1

0

As @hungerstar suggests this is best done outside of mysql. This can be either in the producer or the consumer of the content. If this is a one off job you could perhaps do this in an auxillary script that reads the rows, updates them and inserts them back

Himanshu
  • 2,384
  • 2
  • 24
  • 42