Hello,

I am trying to create a menu in will link to a file in the /files directory, however when I put the path in the "Edit Menu Item" page (i.e. files/hr/f1040.pdf) and his Save, it is linking to "http://localhost/site/index.php?q=hr/f1040.pdf" ... any way to get rid of the full path name that it is putting at the beginning of the path I created? Like a directory tag, or something like that?

Comments

dvessel’s picture

I don't think so. Now why would you want to do this anyways? Drupal is just figuring out the base path for you and inserting it. Makes it more portable when you move off your test server I think. You could setting up a custom block with your own link if you really don't want this behavior.

-joon
www.dvessel.com

drshields’s picture

I would want to do it because it's not pointing to a valid file. The way it works now, it's pointing to index.php-and-then-some-arguments-here. I don't want it to point to index.php at all...I want it to point to /files/myfile ...see what I am saying?

jraper@groups.drupal.org’s picture

Try this - use "../files/hr/f1040.pdf" (remove the quotes) for your Path in the Menu Item. This "backs up" to the DocumentRoot and bypasses index.php.

jraper@groups.drupal.org’s picture

This doesn't seem to work in IE. Not sure what to do that will work in both cases.

jraper@groups.drupal.org’s picture

Try this - use "./files/hr/f1040.pdf" (ONE DOT ONLY) (remove the quotes) for your Path in the Menu Item.

drshields’s picture

I tried both of the following in my PATH for the menu item:

./files/hr/f1040.pdf

../files/hr/f1040.pdf

After applying changes and navigating to the menu, it is still putting the following before my path:

http://localhost/mhfanet/index.php?q=./files/hr/f1040.pdf

Is there another setting that I need to modify somewhere?

jraper@groups.drupal.org’s picture

You must have "Clean URLs" disabled. I have Clean URLs enabled and it works like a charm. If I turn Clean URLs off, I get exactly the behaviour you are describing.

drshields’s picture

Hmmm... Okay, new problem. When I run the 'Clean URL's' checker, it is giving me a page cannot be found error. Here is the link from within drupal that is supposed to run the clean-url check:

http://localhost/mhfanet/index.phpadmin/settings&#clean_url

I've tried putting a slash ( / ) in between the .php and the admin part of that string, but that didn't work either. Any ideas?

jraper@groups.drupal.org’s picture

Cool - now we are getting somewhere. Notice that the paragraph that link is in reads in part:

Before enabling clean URLs, you must perform a test to determine if your server is properly configured. If you are able to see this page again after clicking the "Run Clean URL Test" button, the test has succeeded and the radio buttons above will be available. If instead you are directed to a "Page not found" error, you will need to change the configuration of your server.

Go to this page on Drupal.org for troubleshooting guidance:

http://drupal.org/node/15365

I experienced EXACTLY the same thing you are and was able to get Clean URLs to work by following those instructions. I will of course be happy to help further if you still experience problems. Cheers.

drshields’s picture

I followed the instructions on that page you gave me, including changing the error mapping in IIS for 404 and 405 errors to redirect them to index.php, and I pasted the following code into the bottom of my 'settings.php' file:

$sub_dir = "mhfanet"; // enter a subdirectory, if any. otherwise, use ""
$active = 1; // set to 1 if using clean URLS with IIS

// CODE
if ($active && strstr($_SERVER["QUERY_STRING"], ";")) {
  $qs = explode(";", $_SERVER["QUERY_STRING"]);
  $url = array_pop($qs);
  $parts = parse_url($url);
  unset($_GET, $_SERVER['QUERY_STRING']); // remove cruft added by IIS
  if ($sub_dir) {
    $parts["path"] = substr($parts["path"], strlen($sub_dir));
  }
  $_GET["q"] = trim($parts["path"], "/");
  $_SERVER["REQUEST_URI"] = $parts["path"];
  if ($parts["query"]) {
    $_SERVER["REQUEST_URI"] .= '?'. $parts["query"];
    $_SERVER["QUERY_STRING"] = $parts["query"];
    $_SERVER["ARGV"] = array($parts["query"]);
    parse_str($parts['query'], $arr);
    $_GET = array_merge($_GET, $arr);
    $_REQUEST = array_merge($_REQUEST, $arr);
  }
}

Now, when I run the clean URL's test, I got an error that simply says "No input file specified." If I can't get this to work right, I may just forget about it for the time being, or install Apache and try that.

jraper@groups.drupal.org’s picture

Sorry - I use Apache - I got that to work with little problem. I'm completely unschooled in IIS. Sorry I couldn't help more.