1

If I have multiple domains all pointing to the same website, how are you supposed to write your links so they do not break when used via a different domain, .e.g

Imagine I have the following domains for the same website

oshirowanen.com
oshiro_wanen.com
osh.i.ro.wa.nen.com

if I had a html link as follows

<img src="http://www.oshirowanen.com/images/me.jpg" />

That would only be displayed if users went to oshirowanen.com.

How should that img tag be done properly so it works on all 3 domains?

oshirowanen
  • 15,297
  • 82
  • 198
  • 350
  • 3
    You shouldn't have the same website on multiple domains. Pick one to be canonical and redirect the others to it. – Quentin Apr 05 '11 at 15:07
  • I second that, you need to look into your apache config to rewrite the others (probably the second and third) to copy urls over to the canonical site, e.g. http://wiki.apache.org/httpd/CanonicalHostNames . – Kzqai Apr 05 '11 at 15:10
  • @Tchalvok, I'm trying to do that, but not having much luck: http://stackoverflow.com/questions/5553980/permanent-redirect-via-apache-rewrite-rules – oshirowanen Apr 05 '11 at 15:11

3 Answers3

3

Just

 <img src="/images/me.jpg" />
Matthew Wilson
  • 3,861
  • 21
  • 14
  • Yes, to make it equivalent to the example in the question. (With the "/", it's relative to the root of the site; without the "/", it's relative to the URL of the HTML document.) – Matthew Wilson Apr 05 '11 at 15:13
1

Like this: <img src="/images/me.jpg" />, the src is from the root of whatever domain that page is accessed from.

clmarquart
  • 4,721
  • 1
  • 27
  • 23
0

If all your domains point to the same index, then you can just use relative paths

<img src="images/me.jpg"/>
David
  • 16
  • 4
  • if it's relative to the the html files. if all of your html files are in a folder and you have the images folder inside that folder then the / is not needed. – David Apr 05 '11 at 15:15