Mod_rewrite .htaccess connection to mysql database

I want the mod_rewrite in the .htaccess file to reference the mysql database to provide me with mapping information.

In particular, I use one code base to host several sites, so ... if the user requests an image, for example: http://www.example.com/images/car.jpg

this will hit my server and many other sites will also fall into the / images folder, so I need Apache to reply: / home / example / pubic _html / images / 7383 / car.jpg

Pay attention to the injection "7383", which is a sample site identifier for this user.

Basically, I want to map example.com and 7383 using the mysql database, and then get the correct file for the user.

Any ideas?

+3
source share
2 answers

You can use a script to rewrite a map to get the real path.

+3
source

RewriteMap is the correct Apache functionality to use. Thanks, Gumbo.

Something is unclear how I worked on this:

  • RewriteMap is part of the Apache configuration, not the .htaccess file.
  • I wrote a script to create a text display file that will perform the mapping that I had above. It basically dumps everything that is needed from the database - since mine does not change every minute, I can just run a periodic dump into this text file when the display is added or changed.

. Apache .

+2

All Articles