Jump to content

Recommended Posts

Posted

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

Posted

Try linking to the CSS with :

 

>http://yoururl.com/presentation.css

 

It doesn't have to be in the form of a directory path.

Posted
Try linking to the CSS with :

 

>http://yoururl.com/presentation.css

 

It doesn't have to be in the form of a directory path.

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://....

Posted

Welcome to the forums, manojvp! :P

 

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

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...

Posted
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'>

 

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.

Posted
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?

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.

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...