htaccess - Redirect external url to internal

Discussion in 'Programming' started by Gerben H., Apr 13, 2016.

  1. #1
    Hi

    Is the following possible?
    I have for example the site albums.com with the link to the external site : image.com/album/file.jpg
    Is it possible to Redirect image.com/album/file.jpg to the internal site, so the final link will be albums.com/album/file.jpg

    And is this possible to do this with .htaccess? :)
     
    Gerben H., Apr 13, 2016 IP
  2. fisasti

    fisasti Active Member

    Messages:
    42
    Likes Received:
    5
    Best Answers:
    2
    Trophy Points:
    58
    #2
    Basically you want to redirect the traffic from another site, that's impossible. What you can do (and i don't know if i recommend it), it's redirect certain request (with some .htaccess filter) to one php file and then do the request in the backend. It would be something like:

    .htaccess
    RewriteRule ^(.*)$ index.php?_route=$1 [L,QSA]
    Code (markup):
    index.php
    if (strstr($route, $whatyouarelookingfor)) { //
    // do the proper http request
    }
    Code (markup):
     
    fisasti, Apr 13, 2016 IP