Index: conf/nutch-default.xml
===================================================================
--- conf/nutch-default.xml	(revision 1715149)
+++ conf/nutch-default.xml	(working copy)
@@ -548,12 +548,19 @@
 <property>
   <name>db.ignore.external.links</name>
   <value>false</value>
-  <description>If true, outlinks leading from a page to external hosts
+  <description>If true, outlinks leading from a page to external hosts or domain
   will be ignored. This is an effective way to limit the crawl to include
   only initially injected hosts, without creating complex URLFilters.
+  See 'db.ignore.external.links.mode'.
   </description>
 </property>
 
+<property>
+  <name>db.ignore.external.links.mode</name>
+  <value>byHost</value>
+  <description>Alternative value is byDomain</description>
+</property>
+
  <property>
   <name>db.injector.overwrite</name>
   <value>false</value>
Index: src/java/org/apache/nutch/fetcher/FetcherThread.java
===================================================================
--- src/java/org/apache/nutch/fetcher/FetcherThread.java	(revision 1715149)
+++ src/java/org/apache/nutch/fetcher/FetcherThread.java	(working copy)
@@ -85,6 +85,7 @@
   private boolean redirecting;
   private int redirectCount;
   private boolean ignoreExternalLinks;
+  private String ignoreExternalLinksMode;
 
   // Used by fetcher.follow.outlinks.depth in parse
   private int maxOutlinksPerPage;
@@ -168,8 +169,6 @@
     }
     LOG.info("Using queue mode : " + queueMode);
     this.maxRedirect = conf.getInt("http.redirect.max", 3);
-    this.ignoreExternalLinks = conf.getBoolean("db.ignore.external.links",
-        false);
 
     maxOutlinksPerPage = conf.getInt("db.max.outlinks.per.page", 100);
     maxOutlinks = (maxOutlinksPerPage < 0) ? Integer.MAX_VALUE
@@ -176,6 +175,7 @@
         : maxOutlinksPerPage;
     interval = conf.getInt("db.fetch.interval.default", 2592000);
     ignoreExternalLinks = conf.getBoolean("db.ignore.external.links", false);
+    ignoreExternalLinksMode = conf.get("db.ignore.external.links.mode", "byHost");
     maxOutlinkDepth = conf.getInt("fetcher.follow.outlinks.depth", -1);
     outlinksIgnoreExternal = conf.getBoolean(
         "fetcher.follow.outlinks.ignore.external", false);
@@ -616,19 +616,21 @@
             }
           }
 
-          String fromHost;
+          String origin = null;
 
           // collect outlinks for subsequent db update
           Outlink[] links = parseData.getOutlinks();
           int outlinksToStore = Math.min(maxOutlinks, links.length);
           if (ignoreExternalLinks) {
-            try {
-              fromHost = new URL(url.toString()).getHost().toLowerCase();
-            } catch (MalformedURLException e) {
-              fromHost = null;
+            URL originURL = new URL(url.toString());
+            // based on domain?
+            if ("bydomain".equalsIgnoreCase(ignoreExternalLinksMode)) {
+              origin = URLUtil.getDomainName(originURL).toLowerCase();
+            } 
+            // use host 
+            else {
+              origin = originURL.getHost().toLowerCase();
             }
-          } else {
-            fromHost = null;
           }
           
           //used by fetchNode         
@@ -646,7 +648,7 @@
             String toUrl = links[i].getToUrl();
 
             toUrl = ParseOutputFormat.filterNormalize(url.toString(), toUrl,
-                fromHost, ignoreExternalLinks, urlFilters, normalizers);
+                origin, ignoreExternalLinks, ignoreExternalLinksMode, urlFilters, normalizers);
             if (toUrl == null) {
               continue;
             }
Index: src/java/org/apache/nutch/parse/ParseOutputFormat.java
===================================================================
--- src/java/org/apache/nutch/parse/ParseOutputFormat.java	(revision 1715149)
+++ src/java/org/apache/nutch/parse/ParseOutputFormat.java	(working copy)
@@ -104,6 +104,9 @@
     final int interval = job.getInt("db.fetch.interval.default", 2592000);
     final boolean ignoreExternalLinks = job.getBoolean(
         "db.ignore.external.links", false);
+    final String ignoreExternalLinksMode = job.get(
+        "db.ignore.external.links.mode", "byHost");
+    
     int maxOutlinksPerPage = job.getInt("db.max.outlinks.per.page", 100);
     final boolean isParsing = job.getBoolean("fetcher.parse", true);
     final int maxOutlinks = (maxOutlinksPerPage < 0) ? Integer.MAX_VALUE
@@ -152,7 +155,8 @@
       public void write(Text key, Parse parse) throws IOException {
 
         String fromUrl = key.toString();
-        String fromHost = null;
+        // host or domain name of the source URL
+        String origin = null;
         textOut.append(key, new ParseText(parse.getText()));
 
         ParseData parseData = parse.getData();
@@ -184,15 +188,17 @@
         if (parseMDCrawlDatum != null)
           crawlOut.append(key, parseMDCrawlDatum);
 
+        // need to determine origin (once for all outlinks)
         if (ignoreExternalLinks) {
-          // need to determine fromHost (once for all outlinks)
-          try {
-            fromHost = new URL(fromUrl).getHost().toLowerCase();
-          } catch (MalformedURLException e) {
-            fromHost = null;
+          URL originURL = new URL(fromUrl.toString());
+          // based on domain?
+          if ("bydomain".equalsIgnoreCase(ignoreExternalLinksMode)) {
+            origin = URLUtil.getDomainName(originURL).toLowerCase();
+          } 
+          // use host 
+          else {
+            origin = originURL.getHost().toLowerCase();
           }
-        } else {
-          fromHost = null;
         }
 
         ParseStatus pstatus = parseData.getStatus();
@@ -200,8 +206,8 @@
             && pstatus.getMinorCode() == ParseStatus.SUCCESS_REDIRECT) {
           String newUrl = pstatus.getMessage();
           int refreshTime = Integer.valueOf(pstatus.getArgs()[1]);
-          newUrl = filterNormalize(fromUrl, newUrl, fromHost,
-              ignoreExternalLinks, filters, normalizers,
+          newUrl = filterNormalize(fromUrl, newUrl, origin,
+              ignoreExternalLinks, ignoreExternalLinksMode, filters, normalizers,
               URLNormalizers.SCOPE_FETCHER);
 
           if (newUrl != null) {
@@ -231,8 +237,8 @@
 
           // Only normalize and filter if fetcher.parse = false
           if (!isParsing) {
-            toUrl = ParseOutputFormat.filterNormalize(fromUrl, toUrl, fromHost,
-                ignoreExternalLinks, filters, normalizers);
+            toUrl = ParseOutputFormat.filterNormalize(fromUrl, toUrl, origin,
+                ignoreExternalLinks, ignoreExternalLinksMode, filters, normalizers);
             if (toUrl == null) {
               continue;
             }
@@ -310,14 +316,16 @@
   }
 
   public static String filterNormalize(String fromUrl, String toUrl,
-      String fromHost, boolean ignoreExternalLinks, URLFilters filters,
+      String fromHost, boolean ignoreExternalLinks,
+      String ignoreExternalLinksMode, URLFilters filters,
       URLNormalizers normalizers) {
     return filterNormalize(fromUrl, toUrl, fromHost, ignoreExternalLinks,
-        filters, normalizers, URLNormalizers.SCOPE_OUTLINK);
+        ignoreExternalLinksMode, filters, normalizers,
+        URLNormalizers.SCOPE_OUTLINK);
   }
 
   public static String filterNormalize(String fromUrl, String toUrl,
-      String fromHost, boolean ignoreExternalLinks, URLFilters filters,
+      String origin, boolean ignoreExternalLinks, String ignoreExternalLinksMode, URLFilters filters,
       URLNormalizers normalizers, String urlNormalizerScope) {
     // ignore links to self (or anchors within the page)
     if (fromUrl.equals(toUrl)) {
@@ -324,15 +332,23 @@
       return null;
     }
     if (ignoreExternalLinks) {
-      String toHost;
+      URL targetURL = null;
       try {
-        toHost = new URL(toUrl).getHost().toLowerCase();
-      } catch (MalformedURLException e) {
-        toHost = null;
-      }
-      if (toHost == null || !toHost.equals(fromHost)) { // external links
+        targetURL = new URL(toUrl);
+      } catch (MalformedURLException e1) {
         return null; // skip it
       }
+      if ("bydomain".equalsIgnoreCase(ignoreExternalLinksMode)) {
+        String toDomain = URLUtil.getDomainName(targetURL).toLowerCase();
+        if (toDomain == null || !toDomain.equals(origin)) {
+          return null; // skip it
+        }
+      } else {
+        String toHost = targetURL.getHost().toLowerCase();
+        if (toHost == null || !toHost.equals(origin)) {
+          return null; // skip it
+        }
+      }
     }
     try {
       if (normalizers != null) {
