I have a website, which has numerous subdirectories already. (All existing in server's filesystem) I want to create new "virtual" sub-dirs with htaccess, but I only want the htaccess rule work for directories, listed in DB, and not existing in filesystem.
i.e. File system has: /dir1/ & /dir2/
MySQL database has record for 'dir3' & 'dir4'
And I want:
A: mysite.com/dir1/ and mysite.com/dir2/ display existing old content
B: mysite.com/dir3/ and mysite.com/dir4/ display content from MySQL provided by PHP sctipt via redirect like: mysite.com/myscript.php?dir=dir3
C: mysite.com/dir5/ display 404 error (Dir does not exist in DB nor in Database)
Basically I want .htaccess to work like this: IF DIR Exists in DB - apply the rewrite rule and show content from myscript.php?dir=DIR
ELSE don't apply any rule.
I can create a separate php script, which can return 0/1 when given dir name exist in DB or not, but how do I make mod_rewrite get the data from that script?
Is it possible with htaccess/PHP at all?