...

View Full Version : Need someone to please write me a .htaccess rewrite...



MoreBloodWine
09-14-2011, 02:49 PM
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/usergeneratedimages/MoreBloodWine.png

(Which wont exist after the move...)

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

http://www.gamestatsnow.com/usergeneratedimages/MoreBloodWine.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...

Fou-Lu
09-14-2011, 11:14 PM
...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.

MoreBloodWine
09-14-2011, 11:35 PM
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.


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/usergeneratedimages/MoreBloodWine.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


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.

Fou-Lu
09-15-2011, 08:15 PM
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.

MoreBloodWine
09-15-2011, 09:24 PM
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.

Inigoesdr
09-15-2011, 10:08 PM
I think what Fou-lu is saying is if you used absolute links(hrefs including the domain) instead of relative ones.

Fou-Lu
09-16-2011, 03:57 AM
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.

justin482000
09-16-2011, 04:42 PM
"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

M1Creative
09-18-2011, 05:25 AM
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.

MoreBloodWine
09-18-2011, 05:29 AM
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.

M1Creative
09-18-2011, 05:34 AM
Is this a CMS based website or a hard coded one?

MoreBloodWine
09-18-2011, 05:39 AM
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.

M1Creative
09-18-2011, 05:42 AM
Can you use JS to rewrite the urls for you? Just a thought.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum