Error 403 when viewing images

Discussion in 'Apache' started by Linkzvm, May 14, 2010.

  1. #1
    Okay, this has bugged me for 2 days already and I couldn't find a cure no matter how hard I tried.
    I have a webhost which allows multiple domains, but only pointing to the same website. I used .htaccess to redirect a domain to a folder thus allowing me to run 2 websites on the same webserver.

    However, whenever I try to open an image saved on the second website's /img/ folder with the second domain, it gives me a 403 error. When I open it with the first domain and the folder's name, I can view the image alright.
    Example:

    http://www.seconddomain.com/1.png [ERROR]
    http://www.firstdomain.com/seconddomain.com/1.png [NO ERROR]

    This is the .htaccess I'm using to point the second domain to the folder:

    RewriteEngine On
    Options +FollowSymlinks
    RewriteBase /
    RewriteCond %{HTTP_HOST} seconddomain.com
    RewriteCond %{REQUEST_URI} !seconddomain.com/
    RewriteRule ^(.*)$ seconddomain.com/$1 [L]
    Code (markup):
    This is in the root folder.
    I've already tried to disable hotlinking (with .htaccess) but it still won't work.

    Any ideas?
     
    Linkzvm, May 14, 2010 IP
  2. RAmoss

    RAmoss Guest

    Messages:
    40
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Are you running CPanel? And was the domain added via add-on domains?
     
    RAmoss, May 17, 2010 IP
  3. Linkzvm

    Linkzvm Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank you for replying!
    No, It's not cPanel. The domain is added to point to the root folder, I'm just changing the pointing destination with htaccess. Unfortunately there is no option to configure a domain to run a different website on this host.
     
    Linkzvm, May 17, 2010 IP
  4. Namjies

    Namjies Peon

    Messages:
    315
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Well maybe your host has additional features to prevent you from doing what you're trying to do... But it's a 403 (forbidden) error, so something must be denying access to files.

    If you tried to prevent hotlinking and the code is still there and it's not written properly, it might well be what's denying access. (Denying seconddomain.com as a valid host to access the file).

    Could you add the rest of the .htaccess file and any extra .htaccess file if there's one in that directory?

    ~~~~

    Also,
    RewriteCond %{HTTP_HOST} seconddomain.com
    RewriteCond %{REQUEST_URI} !seconddomain.com/
    RewriteRule ^(.*)$ seconddomain.com/$1 [L]

    I don't understand that thing at all...
    It looks like if domain is seconddomain.com, rewrite /requestedurl to seconddomain.com/requestedurl ... which is exactly same path, same domain. Which wouldn't work???

    Don't your rewrite miss the added seconddomain.com directory in the rewrite?

    ~~~~

    What happens if you try this:
    RewriteCond %{HTTP_HOST} ^seconddomain.com$ [NC]
    RewriteRule ^(.*)$ /seconddomainfolder/$1 [L]

    where if host is seconddomain.com , a url like /category/title.html would instead use /seconddomainfolder/category/title.html (because the seconddomain.com use the same root as firstdomain.com as you specified and you placed seconddomain.com files in the /seconddomainfolder/... )
     
    Last edited: May 19, 2010
    Namjies, May 19, 2010 IP