Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 13 of 13
  1. #1
    Regular Coder
    Join Date
    Nov 2010
    Posts
    204
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Need someone to please write me a .htaccess rewrite...

    Ok, here's the deal... a few things are changing with my site, namely folder paths and URL's. I have over 5k+ images for 5k+ users and I'd like to keep the existing images working under the old URL so...

    If someone uses BBC img tags or HTML's img src tags I need the images to still be able to work and I was told a .htaccess 301 permanent redirect would do the trick.

    So...

    If someone calls...

    http://www.myu2sig.com/usergenerated...eBloodWine.png

    (Which wont exist after the move...)

    I need it to become / show the image at...

    http://www.gamestatsnow.com/usergene...eBloodWine.png

    (Which will be the sites new address...)

    None of those two addresses are in the main public_html directory... they're structured like so.

    myu2sig.com = /public_html/U2Signatures/

    while

    gamestatsnow.com = /public_html/gamestatsnow/

    Ty for your time and interest...

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Quote Originally Posted by MoreBloodWine View Post
    ...None of those two addresses are in the main public_html directory... they're structured like so.

    myu2sig.com = /public_html/U2Signatures/

    while

    gamestatsnow.com = /public_html/gamestatsnow/

    Ty for your time and interest...
    Erm, they look like they are in the public_html to me?
    Anyway, the examples you have provided don't match what you have here. One shows /U2Signatures and /gamestatsnow, while the other simply shows /usergeneratedimages. Which is the case?
    Also, I assume you haven't hardcoded these images to the actual site dns when you are displaying them?

    Moving to Apache Confguration forum.

  • #3
    Regular Coder
    Join Date
    Nov 2010
    Posts
    204
    Thanks
    10
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    Erm, they look like they are in the public_html to me?
    Anyway, the examples you have provided don't match what you have here. One shows /U2Signatures and /gamestatsnow, while the other simply shows /usergeneratedimages. Which is the case?
    I meant that the usergeneratedimages folders are in / on two different sites with two different main URL's as oppoopsed to one URL changing to a new URL all while pointing to the same directory.

    Ex. mysite.com changing to mysites.com all while the folder structuree might look like /public_html/usergeneratedimages/ for both sites.

    Quote Originally Posted by Fou-Lu View Post
    Also, I assume you haven't hardcoded these images to the actual site dns when you are displaying them?

    Moving to Apache Confguration forum.
    The images are store in a folder along with some PHP files. So like if

    http://www.myu2sig.com/usergenerated...eBloodWine.png

    is called the PHP file(s) check the last update time stored in the DB and then update them if the time was 31+ minutes ago.

    ---

    I was told by someone ele that to achieve what I want a 301 redirect will do the trick.

    Edit: I was trying to play with something like this

    Code:
    RewriteCond %{HTTP_HOST} ^gamestatsnow.com/usergeneratedimages/MoreBloodWine.png$
    RewriteRule ^(.*)$ http://www.myu2sig.com/usergeneratedimages/MoreBloodWine.png$1 [R=301,L]
    from one of the many docs I found just testing it against a single image but instead of a redirect to the actual image I get nothing because the image doesnt exist... not that that bit matters since I'm just trying to get the darn thing to redirect to the right / new URL.

    gamestatsnow.com = old site
    myu2sig.com = new site

    gamestatsnow is actually the new site but I havent done much work on it so I'm reversing the roles of the two sites to test the code.
    Last edited by MoreBloodWine; 09-15-2011 at 02:30 AM.

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    If you are using the full dns on your images, then no you are out of luck. HTML will resolve those to the dns provided, so if you have <img src="http://somesite.com/dir/image.png" /> that is where it will go, regardless if your site is somesite.com or notthatsite.com.
    Unless you control BOTH of these dns' in which case you can htaccess from the receiving image back to the originating host, then no you're out of luck and will have to rewrite the html source to not use the DNS (which you shouldn't really have used anyway). You cannot use rewrite to change an external dns to a different one, since it never resolves against the internal host in the first place.

  • #5
    Regular Coder
    Join Date
    Nov 2010
    Posts
    204
    Thanks
    10
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    If you are using the full dns on your images, then no you are out of luck. HTML will resolve those to the dns provided, so if you have <img src="http://somesite.com/dir/image.png" /> that is where it will go, regardless if your site is somesite.com or notthatsite.com.
    Unless you control BOTH of these dns' in which case you can htaccess from the receiving image back to the originating host, then no you're out of luck and will have to rewrite the html source to not use the DNS (which you shouldn't really have used anyway). You cannot use rewrite to change an external dns to a different one, since it never resolves against the internal host in the first place.
    So how do I know if I'm using the DNS or not ?

    If I can get this image redirect deal working it is something I'd like to do so I dont have to leave the image fodler on the opld site and have all new images go to it.
    Last edited by MoreBloodWine; 09-15-2011 at 09:28 PM.

  • #6
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    I think what Fou-lu is saying is if you used absolute links(hrefs including the domain) instead of relative ones.

  • #7
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Quote Originally Posted by Inigoesdr View Post
    I think what Fou-lu is saying is if you used absolute links(hrefs including the domain) instead of relative ones.
    You seem to have trailed off there lol.
    But yes, if you have used the absolute web name to the images in your img tag src, you cannot intercept these outgoing from your page. You don't control that, the client does, so when they see an img src on a remote location they will fetch it from there. You can redirect back to the originating location IF you control both of these websites.

  • #8
    New to the CF scene
    Join Date
    Aug 2011
    Posts
    5
    Thanks
    0
    Thanked 1 Time in 1 Post
    "Need someone to please write me a .htaccess rewrite..."

    if you have a site with 5k+ users, I believe you should be making some decent money.

    it would not cost you so much to hire someone who is an expert to do this job for you

  • #9
    New Coder
    Join Date
    Aug 2011
    Location
    Melbourne, Brighton 3186
    Posts
    17
    Thanks
    1
    Thanked 2 Times in 2 Posts
    That's a bit tough. I think it is great that he is making an effort to learn how to do it in the first place.

  • #10
    Regular Coder
    Join Date
    Nov 2010
    Posts
    204
    Thanks
    10
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by M1Creative View Post
    That's a bit tough. I think it is great that he is making an effort to learn how to do it in the first place.
    An effort I'm still working on but I may end up going an alternative route and leaving the images under the old domain while the site works underthe new one.

  • #11
    New Coder
    Join Date
    Aug 2011
    Location
    Melbourne, Brighton 3186
    Posts
    17
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Is this a CMS based website or a hard coded one?

  • #12
    Regular Coder
    Join Date
    Nov 2010
    Posts
    204
    Thanks
    10
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by M1Creative View Post
    Is this a CMS based website or a hard coded one?
    Everythings done through PHP files & some JS, the JS though is mostly for the selector on the main site of myu2sig.com which is where everything currently resides.

  • #13
    New Coder
    Join Date
    Aug 2011
    Location
    Melbourne, Brighton 3186
    Posts
    17
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Can you use JS to rewrite the urls for you? Just a thought.


  •  

    Posting Permissions

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