htaccess newb: if file !exists, redirect...

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
The Monkey
Forum Contributor
Posts: 168
Joined: Tue Mar 09, 2004 9:05 am
Location: Arkansas, USA

htaccess newb: if file !exists, redirect...

Post by The Monkey »

Hello there,

I would like an htaccess script that, when someone goes to mysite.com/foobar.html, checks to see if the file foobar.html exists, and if it DOESN'T, tell it to display pagefromdb.php?page=foobar.html (while leaving the url in the browser as mysite.com/foobar.html).

Here is what I need in pseudo code:

Code: Select all

if file exists {this_page} == false
display pagefromdb.php?page={this_page}
else
display {this_page} //file
Could one of you point me in the right direction for what I need to do?

I hope I was clear enough...

- Monkey
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

look at the mod_rewrite thread just below this.
Post Reply