Jump to content


No extensions with file and directory of same name

  • Please log in to reply
No replies to this topic

#1 ryanb

  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 22 September 2006 - 04:13 AM


I have run into a problem updating a site to use extension-less filenames in things like anchors, where the old version says, <a href="test.php">, but I want the new version to say <a href="test"> (no extension).  The problem is that there are some directories with the same names as files, like test/ .

I have MultiViews turned-on, so when I use <a href="test">, I get the directory test/ instead of the file test.php .

I am trying to use mod_rewrite to solve this, but the only way I can get close is to use

RewriteRule ^test/$ test.php [R]

The problem with that is it shows "test.php" in the URL.  If the "[R]" is not used, the HTML of the page will show-up okay, but links to styles sheets and images don't work because the paged is displayed as if it were one directory level deeper than it is (because/and the URL will show "test/", with the slash).

My initial thought, which doesn't work, was

RewriteRule ^test$ test.php

but it seems that MultiViews acts before rewriting because that rule will have no effect and I will get the directory because I guess MultiViews will go for a directory before a file of the same name.

Thank you very much!

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users