manojvp Posted June 27, 2005 Posted June 27, 2005 Are these two lines the same thing? I thought they are /home/username/public_html/images/aspen100x800.jpg http://www.organswap.org/images/aspen100x800.jpg I can see the picture when I use the http://.... but when I use the first line in "image=..." It doesn't work. Please advice. I am trying to set up a subdomain and I was experimenting with some of the path. and thats where I came across the previous problem. Here is what I was trying to do with subdomain. All my files are in the "public_html" folder including the "layout.css" Images are in "/public_html/images/". They work well in the main domain. I set the path in "/public_html/.htaccess" as "/home/username/public_html/:/home/username/public_html/images/" This doesn't seem to be working. In purticluar, it can not find the .css files. The code in index.php is <link rel="stylesheet" type="text/css" href='presentation.css'> I also tried <link rel="stylesheet" type="text/css" href='/home/username/public_html/presentation.css'> I also tried <link rel="stylesheet" type="text/css" href="/home/username/public_html/presentation.css"> none of them worked Can anyone please help? Thanks Quote
marie b. Posted June 27, 2005 Posted June 27, 2005 Try linking to the CSS with : >http://yoururl.com/presentation.css It doesn't have to be in the form of a directory path. Quote
manojvp Posted June 27, 2005 Author Posted June 27, 2005 Try linking to the CSS with : >http://yoururl.com/presentation.css It doesn't have to be in the form of a directory path. <{POST_SNAPBACK}> Thanks Yes that worked. I still have to solve this for the images and the other folders too though. and I thought I read some where that its not a good idea to point using the http://.... Quote
TweezerMan Posted June 27, 2005 Posted June 27, 2005 Welcome to the forums, manojvp! Are these two lines the same thing? I thought they are /home/username/public_html/images/aspen100x800.jpg http://www.organswap.org/images/aspen100x800.jpg <{POST_SNAPBACK}> These are not the same thing - they are two different ways to point at the same location. The first is a local server path, and the second is a URL. A local server path can only be used by a script running locally on the server - you can't use it in the HTML of a web page. What you're trying to come up with is what's known as a 'relative URL' - basically a partial URL, or a URL 'path'. To link to your stylesheet in your web page, instead of linking with a full URL like this: ><link rel="stylesheet" type="text/css" href='http://www.organswap.org/presentation.css'> ...you could link to it with a relative URL like this, omitting the domain portion of the URL: ><link rel="stylesheet" type="text/css" href='/presentation.css'> When the web page is loaded in the browser, the browser will complete the relative URL with the domain name from the web page's URL to get the full URL of the stylesheet. The advantage to using relative URLs wherever you can is that if you ever decided to change the domain name for your web site, relative links to other pages and files on your web site will still work and not be broken - you won't have to edit every link to replace the old domain name with the new one. You can also link to images with a relative URL. This full URL: >http://www.organswap.org/images/aspen100x800.jpg ...can be replaced with this relative URL: >/images/aspen100x800.jpg A relative URL that starts with "/" is relative to the root of the domain (like the examples I've shown above). You can also use relative URLs that do not start with "/" - these URLs are relative to the URL of the web page that it appears on. I usually recommend not using relative URLs that aren't relative to the root of the domain - links using this type of relative URL are easily broken. Hope this helps... Quote
manojvp Posted June 28, 2005 Author Posted June 28, 2005 Welcome to the forums, manojvp! ..................................................... Hope this helps... <{POST_SNAPBACK}> Thanks for your help David. and Hello to every one else! Quote
manojvp Posted June 28, 2005 Author Posted June 28, 2005 What you're trying to come up with is what's known as a 'relative URL' - basically a partial URL, or a URL 'path'. To link to your stylesheet in your web page, instead of linking with a full URL like this: ><link rel="stylesheet" type="text/css" href='http://www.organswap.org/presentation.css'> ................................. ...you could link to it with a relative URL like this, omitting the domain portion of the URL: ><link rel="stylesheet" type="text/css" href='/presentation.css'> <{POST_SNAPBACK}> This (href='/presentation.css'>) works when I am under the main domain. now I am trying to do this from a subdomain. "presentation.css" is still under the public_html folder. Is there any restriction on refering files from subdomain html to a file in the main domain? <?php includes with complete path (/home/.....) seem to be working but not the html ones. Quote
TCH-Rob Posted June 28, 2005 Posted June 28, 2005 What about; >../presentation.css Assuming the page calling the CSS file is one folder below public_html Quote
manojvp Posted June 28, 2005 Author Posted June 28, 2005 What about; >../presentation.css Assuming the page calling the CSS file is one folder below public_html <{POST_SNAPBACK}> thats not working either Quote
TweezerMan Posted June 28, 2005 Posted June 28, 2005 This (href='/presentation.css'>) works when I am under the main domain. now I am trying to do this from a subdomain. "presentation.css" is still under the public_html folder. Is there any restriction on refering files from subdomain html to a file in the main domain? <{POST_SNAPBACK}> On a page within a subdomain, you can't use a relative URL to refer to a page outside of the subdomain. If you wanted to link to a file in your main domain, you'd need to use a full URL. <?php includes with complete path (/home/.....) seem to be working but not the html ones. <{POST_SNAPBACK}> That's because PHP code is script code that is run locally on the server: A local server path can only be used by a script running locally on the server Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.