views:

145

answers:

2

Hi. I'm writing a script to build a dynamic website, the website is created by loading external components.

The DocumentRoot is location at /sites/website/public the components directory is located at /sites/website/components

i wannna reach the data directory of each component depends on the requested url.

for example:

the url:

http://ibuildmywebsite/component-data/randomimage/demo/swan04090044%5Fsmall.jpg

should fetch the file /sites/website/components/randomimage/data/demo/swan04090044_small.jpg

how can i achieve that ? i would prefer a way that can be placed inside .htaccess (if there is one) instead of modifying the virtual host definitions.

Thanks!

+3  A: 

Combine RewriteRule with Alias maybe ?

Alias /randomimage /sites/website/components/randomimage
RewriteRule ^component-(.*)/randomimage/(.*)$ /randomimage/$1/$2 [R,L]

(Won't work in .htaccess though)

You could probably also use Symlinks with:

Options +FollowSymLinks

And link dynamically components-/randommimage/ to /sites/website/components/randomimage///

Oct
I cannot combine RewriteRule with alias because i don't know the name of the directory that the component is located.Symlinks would work but as far as i know windows doesn't have symlinks and i want this application to work on all os's.
ufk
Then you probably need to give us more than one example on what you want to achieve exactly...If this is really dynamic stuff (like no part of the url ever stays the same), I'm afraid this might have to be implemented in the Application logic directly.
Oct
I understand now that what i want to achieve can only be implemented in the Application logic. thanks!!
ufk
A: 

Try this rule:

RewriteRule ^component-data/randomimage/demo/([^/]+)$ /sites/website/components/randomimage/data/demo/$1
Gumbo