Jump to content

Archived

This topic is now archived and is closed to further replies.

ryanb

No extensions with file and directory of same name

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!

Share this post


Link to post
Share on other sites

×

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.