views:

37

answers:

1

I am making a site with photo albums for agents. Each agent has his folder with .css file. Each agent dir has album folders with index.php and .css

/example.com/
    /agent001/
    agent001.css
        /000005/
        index.php
        main.css
        /photos/
            aaa.jpg
            bbb.jpg
        /000006/
        index.php
        ...
    /agent002/
    agent002.css
        /000009/
        ...

So the path to agent's 000005 album would be: /agent001/000005/index.php

I want a shortcut like: /000005/ which forwards to /agent001/000005/some-title-here

Another thing I can't really get my head around is my dir structure. I really need the agent and album folders to organize my stuff. But index.php and main.css are all the same, should I move these files to the root?

Any help greatly appreciated!

A: 

That is not possible with mod_rewrite. You would need some program that walks through the agent directories an checks if there is a folder with that name.

But besides that your short URLs would not be distinct any more. Because like Max S. said in the comments, how should /000005/ be mapped if more than one agent has an album “000005”? Or is this value unique for all agents?

And using a central instance of index.php and main.css is the best choice to avoid redundancy and complexity. In that case you could use mod_rewrite to rewrite requests to your central files like:

RewriteRule ^[^/]+/[^/]+/index\.php$ /index.php
Gumbo
sorry I didn't make that clear.. /000005/ is only owned by agent001.All the these album folders are unique (they are actually the date of the photoshoot)Thanks for the answer about centralizing index.php and main.css
FFish