jnroche Posted March 13, 2008 Share Posted March 13, 2008 Hi!I've been using htaccess to rewrite my urls and hide the actual filenames of my site on the address bar. However, say, within my PHP files or html files all references are absolute, example in the image tag:<img src="http://www.mysite.com/images/image1.jpg" />this would make it load longer right?are there any recommendations?thanks so much guys! Link to comment Share on other sites More sharing options...
real_illusions Posted March 13, 2008 Share Posted March 13, 2008 Shouldn't make any difference to loading time whether you use absolute or relative url's. Unless you have about 10 million links on your page, then all those extra bits of text to make up the absolute url will make your file size alot bigger. I shouldn't worry about it...and how is this got to do with the htaccess and url rewriting? Link to comment Share on other sites More sharing options...
boen_robot Posted March 13, 2008 Share Posted March 13, 2008 I'd use relative paths wherever possible. Makes code smaller AND more portable (imagine you decide to change the domain name one day - wouldn't want to go over all links just to make that change, would you?).But yeah. What does this have to do with URL rewriting? If you're worried URL rewriting is going to slow down the loading of images, place them in a folder that doesn't get rewritten. That is, make sure your URL rewriting rule rever rewrite the URLs from that directory. Link to comment Share on other sites More sharing options...
jnroche Posted March 13, 2008 Author Share Posted March 13, 2008 Thanks for replying guys!I normally use relative paths for all links inside my pages. however, since i used htaccess to rewrite urls, my images does not load up. But if I change my relative paths to absolute it loads up! And changing my domain will really be a problem if i use absolute paths...how come that when i rewrite my urls, relative paths does not work anymore? or am i doing something wrong? Link to comment Share on other sites More sharing options...
boen_robot Posted March 13, 2008 Share Posted March 13, 2008 Thanks for replying guys!I normally use relative paths for all links inside my pages. however, since i used htaccess to rewrite urls, my images does not load up. But if I change my relative paths to absolute it loads up! And changing my domain will really be a problem if i use absolute paths...how come that when i rewrite my urls, relative paths does not work anymore? or am i doing something wrong?Try to write your paths relative to the document root. That is, use for example/images/image1.jpg instead of plain images/image1.jpg The latter can resolve to http://www.mysite.com/file/images/image1.jpg if the file was at http://www.mysite.com/file/ Link to comment Share on other sites More sharing options...
jnroche Posted March 14, 2008 Author Share Posted March 14, 2008 Try to write your paths relative to the document root. That is, use for example/images/image1.jpg instead of plain images/image1.jpg The latter can resolve to http://www.mysite.com/file/images/image1.jpg if the file was at http://www.mysite.com/file/ It worked like a charm!Thanks so much man! really appreciate it. Seems there really is an issue with urls without the '/' sign when using htaccess, thats why it won't recognize paths without the preceeding '/'.Problem solved! Thanks again Gurus! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.