views:

82

answers:

2

Hi,

I have a website which I am updating the URLs for i.e. rewriting to be more SEO friendly. By doing this, it has broken a lot of the links to scripts/images on the various pages. The only way around this (from what I can tell) is to use the absolute path to the scripts/images on the pages.

Now unless I am mistaken (or missing something) this should be pretty safe to do? Anyone who knows anything about websites and/or web development would be able to work out directories to images/scripts by simply looking at the current URL and matching it up against the relative paths anyways.

I would like to know if there are any real reasons why this would be an issue.

Thanks.

+3  A: 

There are absolutely no security implications for using absolute URIs instead of relative URIs.

David Dorward
Thanks just needed some clarification
James
+4  A: 

There are no security implications, but it will make life harder for you if you ever move your site (e.g. to a different domain), since you'll have to update all URLs from http://www.example.com/media/mynicepicture.jpg to http://www.mynewexample.com/media/mynicepicture.jpg. If you use relative URLs, you don't need to update your URLs if/when you move domains.

Dominic Rodger
Note that you fix that by simply omitting the domain name (i.e. `/media/mynicepicture.jpg` is an absolute in the current domain) but you still have the same issue when you rename `/media`.
Aaron Digulla
Thanks, yeah this is something that shouldn't really be something that will happen very often so should be ok. @Aaron, this would be the case anyway if you rename any folder, you would need to update the links.
James
@Aaron, great point.
Dominic Rodger
@James - not quite right, if you had relative links from files within `media/` to other files within `media/` (e.g. `media/css/style.css` referenced `/media/images/foo.jpg` using `../images/foo.jpg`), you wouldn't have to update relative links if you renamed `media` to `whatever`.
Dominic Rodger
Yeah point taken, however, I was referring to having folders explictly defined in the path i.e. "images/myimage.jpg" If I renamed "images" to "media" I would therefore have to update that link.
James