CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2011
    Posts
    3

    .htaccess, redirect to HTTP_HOST specific folder.

    I'm trying to have the server lookup files/images in a different folder, than typed in the address bar.

    For example, if somebody types
    http://my-domain.com/images/test.jpg
    the server should look for the image in:
    /images/my-domain.com/test.jpg and not /images/test.jpg as it normally would.

    I've managed to get the domain-name into the RewriteRule, but it still isn't working:
    RewriteRule ^images/(.*) images/%{HTTP_HOST}/$1 [L]

    This WORKS:
    RewriteRule ^images/(.*) images/%{HTTP_HOST}/test.jpg [L]
    But here the image, test.jpg, is hard-coded which it of course shouldn't be.

    Can anybody help? And does it make any sense?

  2. #2
    Join Date
    May 2002
    Posts
    10,943

    Re: .htaccess, redirect to HTTP_HOST specific folder.

    Oh so close. Try the following instead...

    Code:
    RewriteRule ^images/(.*)$ images/%{HTTP_HOST}/$1 [L]
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    Feb 2011
    Posts
    3

    Re: .htaccess, redirect to HTTP_HOST specific folder.

    Well, it does something else now.

    But in my error log I now get (I didn't get that before):
    Request exceeded the limit of 10 internal redirects due to probable configuration error

  4. #4
    Join Date
    May 2002
    Posts
    10,943

    Re: .htaccess, redirect to HTTP_HOST specific folder.

    Try it without the parenthetical regular expression.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  5. #5
    Join Date
    Feb 2011
    Posts
    3

    Re: .htaccess, redirect to HTTP_HOST specific folder.

    This made the trick:
    RewriteCond %{REQUEST_URI} !^/uploads/.*?/.*$

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured