PDA

View Full Version : killer htaccess question... how to target parent directory?



Birmingham
11-20-2010, 10:37 PM
hi guys, i have a htaccess line that looks somethihng like this:

RewriteRule ^alpha.jpg$ ../alpha.jpg [L]

basically as you can see it is trying to target an equivalent file in the parent directory, but it only returns a bad request because i guess the double-dot-and-slash ( ../ ) is not recognised in htaccess like it would be in a php script?

it's so hard finding anyone who knows htaccess like the back of their hand, and so hard finding somewhere to ask for help with advanced htaccess... does anyone have a solution to this problem? :confused:

djr33
11-21-2010, 12:14 AM
You can set the rewrite base to the higher directory. Then treat the first item as dir/alpha.jpg and the second as just alpha.jpg-- you can also use $1 (I believe) and that will use the matched item (alpha.jpg) as the value in the second part.
I haven't tested this, but since you said it's hard to find help (and it is), this is how I'd start. I'm not an expert either but if you play with the settings for long enough you can usually find a way for it to work.