Results 1 to 2 of 2

Thread: killer htaccess question... how to target parent directory?

  1. #1
    Join Date
    Jun 2006
    Location
    Birmingham
    Posts
    39
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Unhappy killer htaccess question... how to target parent directory?

    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?

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. The Following User Says Thank You to djr33 For This Useful Post:

    Birmingham (11-21-2010)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •