Hello,

I am using the following setup:
Xampp local host server
Drupal 5.7
Drigg 1.31
Views 1.6
Voting API 1.6
User Karma 1.8
Tagadelic 1.0
CCK 1.7

Everything works well except for when I try to browse one of my tags.
I set up everything according to the instructions so that I have a scoop with the following fields:

Node Title
link
time of post
Category: business (for example)
Tags: business, sales (for example)

Now, if I click on the category item I get sent to the page:
http://localhost/drupal-5.7/tag/business

And if I clink on one of the tags I get sent to:
http://localhost/drupal-5.7/tag/business
http://localhost/drupal-5.7/tag/sales

All these pages return the following error:

Access forbidden!

You don't have permission to access the requested object. It is either read-protected or not readable by the server.

If you think this is a server error, please contact the webmaster.
Error 403
localhost
05/11/08 13:44:51
Apache/2.2.8 (Win32) DAV/2 mod_ssl/2.2.8 OpenSSL/0.9.8g mod_autoindex_color PHP/5.2.5

The thing is if I browse to the category using the url:
http://localhost/drupal-5.7/business (note: without the "tag" dir)
I get to the "published scoops" page and see all the relevant scoops in the category.
So I assume the problem is with the "tag" url rewrite module.
I tried applying different settings to my xampp settings as suggested here:
http://drupal.org/node/75537 but I still continue to get the errors.

Any idea how to solve this one?

Thanks in advance,
Nimi.

Comments

mercmobily’s picture

Hi,

This is really odd.
Can you please include:

* Your custom_url_rewrite function
* The actual server's error log

...?
Do you by any chance have a directory called "tag" in your servers' root directory? (you shouldn't)

Bye,

Merc.

nimi’s picture

Hi,
Thanks for your quick reply.

I checked for a "tag" directory on root - there isn't one.

custom_url_rewrite_function.php:

function custom_url_rewrite($op, $result, $path, $path_language=NULL) {

  $term_list=variable_get("drigg_section_list",array());
  $tag_vid=variable_get('drigg_tag_vid','');

  // This is OUTGOING stuff
  if($op == 'alias'){


    // Make outgoing links look right
    if (preg_match('|^node/([^/]+)(.*)$|', $path, $matches)) {
      $n = $matches[1];
      $rest = $matches[2];

      if(is_numeric($n)){
        $res= drigg_settings_lookup_drigg_node_by_dnid($n);
        if($res){
          // Return the right URL
          $safe_section=$res->safe_section;
          $title_url=$res->title_url;
          // I hate this, but we need to have it because you never know
          $safe_section = $safe_section != '' ? $safe_section : 'All';
          return("$safe_section/$title_url$rest");
        }
      }
    }

    // Make TAG links look right
    if (preg_match('|^taxonomy/term/([0-9]+)(/?)(.*)$|', $path, $matches)) {

      if($matches[3] == ''){
        $tid = $matches[1];
        $res=drigg_settings_lookup_term_name_by_tid($tid);
        if($res){
          $res=urlencode($res);
          return("tag/".$res);
        }
      }

    }


    // Make users look right 
    if (preg_match('|^user/([^/]+)(.*)$|', $path, $matches)) {
      $uid = $matches[1];
      $rest = $matches[2];
      $res=drigg_settings_lookup_user_name_by_uid($uid);
      if($res){
        $res=urlencode($res);
        return("users/${res}${rest}");
      }
    }
       

  }

  // This is INCOMING requests
  if($op == 'source'){

    // Change the INCOMING links, so that people can view
    // www.a.com/Community/Embedded_Linux_pioneer_offers_webinar/ or even
    // www.a.com/Community/Embedded_Linux_pioneer_offers_webinar/edit
    // 
    if(preg_match('%^(.*?)/([^/]+)(.*)$%', $path, $matches)){
      $cat = $matches[1];
      $title_url = $matches[2];
      $rest = $matches[3];
      if( isset($term_list['by_safe_name'][$cat]) || $cat== 'All'){
        $res=drigg_settings_lookup_drigg_node_by_title_url($matches[2]);
        if($res){
          $nid=$res->dnid;
          $safe_section = $res->safe_section;

          // Check that the article's category matches the requested
          // one. This is not strictly necessary
          /* if($cat != "All" && $cat != $safe_section){
            return 'file_not_found';
          }*/ 

          return 'node/'.$nid.$rest;
        }
      }
    }


    // Change /tag/pippo into taxonomy/term/33
    if(preg_match('%^tag/([^/]+)$%', $path, $matches)){
      $tag = urldecode($matches[1]);
      $tid= drigg_settings_lookup_term_tid_by_name($tag);
      
      if($tid){
        return 'taxonomy/term/'.$tid;
      }
    }

    // Change /users/pippo into user/33
    if (preg_match('|^users/([^/]+)(.*)$|', $path, $matches)) {
      $name = urldecode($matches[1]);
      $rest = $matches[2];
      $res=drigg_settings_lookup_user_uid_by_name($name);

      if($res){
        return("user/${res}${rest}");
      }
    }

  }

  return $result;
}


function drigg_settings_lookup_term_tid_by_name($name){
  static $cache;

  if(!$cache[$name]){
    $res=db_result(db_query("SELECT tid FROM {term_data} WHERE name ='%s'",$name));
    $cache[$name]=$res;
  }
  return $cache[$name];
}

function drigg_settings_lookup_term_name_by_tid($tid){
  static $cache;


  if(!$cache[$tid]){
    $res=db_result(db_query("SELECT name FROM {term_data} WHERE tid =%d",$tid));
    $cache[$tid]=$res;
    #drupal_set_message("HERE: SELECT name FROM {term_data} WHERE tid =$tid: $res");

  }
  return $cache[$tid];
}

function drigg_settings_lookup_drigg_node_by_dnid($dnid){
  static $cache;

  if(!$cache[$dnid]){
    $res=db_fetch_object(db_query("SELECT safe_section,title_url FROM {drigg_node} WHERE dnid ='%d'",$dnid));
    $cache[$dnid]=$res;
  }
  return $cache[$dnid];
}

function drigg_settings_lookup_drigg_node_by_title_url($title_url){
  static $cache;

  if(!$cache[$title_url]){
        $res = db_fetch_object(db_query("SELECT dnid,safe_section FROM {drigg_node} WHERE title_url ='%s'",$title_url));
    $cache[$title_url]=$res;
  }
  return $cache[$title_url];
}


function drigg_settings_lookup_user_uid_by_name($name){
  static $users;

  if(!$users[$name]){
    $uid= db_result(db_query("SELECT uid FROM {users} WHERE name ='%s'",$name));
    $users[$name]=$uid;
  }
  return $users[$name];
}
function drigg_settings_lookup_user_name_by_uid($uid){
  static $users;

  if(!$users[$uid]){
    $name= db_result(db_query("SELECT name FROM {users} WHERE uid =%d",$uid));
    $users[$uid]=$name;
  }
  return $users[$uid];
}

Server's error log:

[Sun May 11 19:33:20 2008] [notice] Apache/2.2.8 (Win32) DAV/2 mod_ssl/2.2.8 OpenSSL/0.9.8g mod_autoindex_color PHP/5.2.5 configured -- resuming normal operations
[Sun May 11 19:33:20 2008] [notice] Server built: Jan 18 2008 00:37:19
[Sun May 11 19:33:20 2008] [notice] Parent: Created child process 4360
[Sun May 11 19:33:22 2008] [notice] Child 4360: Child process is running
[Sun May 11 19:33:22 2008] [notice] Child 4360: Acquired the start mutex.
[Sun May 11 19:33:22 2008] [notice] Child 4360: Starting 250 worker threads.
[Sun May 11 19:33:22 2008] [notice] Child 4360: Starting thread to listen on port 443.
[Sun May 11 19:33:22 2008] [notice] Child 4360: Starting thread to listen on port 80.
[Sun May 11 19:33:29 2008] [error] [client 127.0.0.1] File does not exist: C:/xampp/htdocs/misc, referer: http://localhost/drupal-5.7/
[Sun May 11 19:33:29 2008] [error] [client 127.0.0.1] File does not exist: C:/xampp/htdocs/misc, referer: http://localhost/drupal-5.7/
[Sun May 11 19:33:37 2008] [error] [client 127.0.0.1] File does not exist: C:/xampp/htdocs/misc, referer: http://localhost/drupal-5.7/business/
[Sun May 11 19:33:37 2008] [error] [client 127.0.0.1] File does not exist: C:/xampp/htdocs/misc, referer: http://localhost/drupal-5.7/business/
[Sun May 11 19:33:46 2008] [error] [client 127.0.0.1] client denied by server configuration: C:/xampp/htdocs/drupal-5.7/tag, referer: http://localhost/drupal-5.7/business/
[Sun May 11 19:34:51 2008] [error] [client 127.0.0.1] client denied by server configuration: C:/xampp/htdocs/drupal-5.7/tag, referer: http://localhost/drupal-5.7/business/

Thanks,
Nimi.

mercmobily’s picture

Hi,

I don't understand the logs. Are you actually clicking on http://localhost/drupal-5.7/tag/business ? Or Just on /tag?

Please send me *only* th error log lines which pop out *precisely* when you click on a tag, and please double-triple check that you're actually clicking on a link with the tag name following it.

This problem is due to a server configuration, and you seem to be using Apache under Windows. I can try and direct you towards the right direction, but I don't really support anything but Apache on Linux. With this sort of problem, you are better off asking the Drupal forums (there are more Windows users there)

Bye,

Merc.

nimi’s picture

Ok thanks Merc I'll try first uploading my site to a Linux server to see if it will solve the problem.

mercmobily’s picture

Status: Active » Fixed

Hi,

OK thanks :-D
I will close the issue for now, because I am basically 99.99999% sure it was a server misconfiguration...

Merc.

mercmobily’s picture

Status: Fixed » Closed (fixed)
chrisdfeld’s picture

Apologies for resurrecting an old issue, but I encountered the same problem today and wanted to report the solution. I'm running Drupal 6.14, also under Apache on Windows. Please note that I'm not using the Drigg module. This issue isn't specific to any particular module.

The symptom, as described above, is getting an HTTP 403 error ("Access Forbidden") when visiting a URL like /tag/mytag. The "access forbidden" page you see is a plain vanilla Apache error page, not a Drupal error page. The cause of the error is this code at the top of Drupal's .htaccess file:

# Protect files and directories from prying eyes.
<FilesMatch "\.(engine|inc|info|install|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl|svn-base)$|^(code-style\.pl|Entries.*|Repository|Root|Tag|Template|all-wcprops|entries|format)$">
  Order allow,deny
</FilesMatch>

That code is intended to prevent requests for certain files that might be dangerous to serve in some circumstances. Notice that Tag (with a capital "T") is one of the phrases listed above. Because Windows uses a case-insensitive filesystem, that phrase also unintentionally matches the all-lowercase URL /tag/mytag. This isn't a problem on Unix servers because the filesystem in case-sensitive.

A fix for this is to delete the Tag| bit from the FilesMatch directive in Drupal's .htaccess. You can then use Drupal URLs in the format /tag/mytag. You'll need to remember to re-apply the same change whenever you upgrade Drupal.