Jump to content

No extensions with file and directory of same name


ryanb

Recommended Posts

Hello,

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

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

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

[font=Courier]RewriteRule ^test/$ test.php [R][/font]

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

[font=Courier]RewriteRule ^test$ test.php[/font]

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!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.