Page 1 of 1

Php created list in .htaccess

Posted: Mon Jun 20, 2005 9:52 pm
by Todd_Z
I am going to have about 200 pages which I would like to have in the form

http://www.domain.com/Page Name/

which would be mod_rewritten into

http://www.domain.com/landingPage.php?k=Page Name

I only want to redirect the pages that are present in a mysql database. Is it possible to mod_rewrite based on a list outputt by a php file [the php file would read all entries in a table and echo them].

Posted: Tue Jun 21, 2005 6:59 am
by Chris Corbyn
Since .htaccess is read before any content is served you won't be able to do it in realtime. The only thing I can think of is to have CRON run every 30 mins or whatever and modify your .htaccess file based upon the database contents...

It's not perfect though.

EDIT | Depending upon how your database is managed you may even be able to have a PHP script update the .htaccess file in synchronisation with updates to the database :idea:

Posted: Tue Jun 21, 2005 7:40 am
by Syranide
What the, I though I answered this one...
Well well, eitherway, why can't you just mod_rewrite to a static php-file? (the sent address can be found in $_SERVER)

That way the script can do some nice db-query, view the page, do a redirect (if you want it that way), or thrown an error if it is desired.

Works really well.