/file will read try to read /file.???

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

/file will read try to read /file.???

Post by Skara »

I'm pretty sure I've seen it before, but I can't remember what it was.
First I do this:
example.com/foo
translate into
example.com/files/foo
via mod_rewrite. That part is easy.

Then I want it to see if foo.php exists. If not, look for foo.pl or something. If nothing starts with "foo." then give a 404.

This is possible, right? *crosses fingers*
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

Are you particularly averse to using a php script to do this? If not you could map example.com/foo -> example.com/files/getfile.php?file=foo using mod_rewrite, then use getfile to do the rest.

This seems to be the easiest way to do it, assuming of course you don't mind/can use php.
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Post by Skara »

hmm. well. I suppose I'm just having one of those moments. Thanks. :P
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

That's why we're here :)
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Post by Skara »

hmm..

Ok, I'm doing something different. Still having problems, though.

Code: Select all

RewriteRule ^files/.* / їR]
  RewriteRule ^(їA-Za-z_\-]+)/?$ files/F_$1.sk їL]
Yeah, everything redirects.

Ok, so what I want to do is this... If a file in files/ is accessed directly, redirect to the main site (actually, I'd rather have an error page--that possible?). The second is my solution to the above problem. Just give all the files the same extension and be done with it. :P
Post Reply