LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Trailing slash problem in apache... or DNS? (https://www.linuxquestions.org/questions/linux-newbie-8/trailing-slash-problem-in-apache-or-dns-331128/)

Swakoo 06-07-2005 03:21 AM

Trailing slash problem in apache... or DNS?
 
Quote:

Why does accessing directories only work when I include the trailing "/" (e.g., http://foo.domain.com/~user/) but not when I omit it (e.g., http://foo.domain.com/~user)?

When you access a directory without a trailing "/", Apache needs to send what is called a redirect to the client to tell it to add the trailing slash. If it did not do so, relative URLs would not work properly. When it sends the redirect, it needs to know the name of the server so that it can include it in the redirect. There are two ways for Apache to find this out; either it can guess, or you can tell it. If your DNS is configured correctly, it can normally guess without any problems. If it is not, however, then you need to tell it.

Add a ServerName directive to the config file to tell it what the domain name of the server is.

The other thing that can occasionally cause this symptom is a misunderstanding of the Alias directive, resulting in an alias working with a trailing slash, and not without one. The Alias directive is very literal, and aliases what you tell it to. Consider the following example:

Alias /example/ /home/www/example/


The above directive creates an alias for URLs starting with /example/, but does not alias URLs starting with /example. That is to say, a URL such as http://servername.com/example/ will get the desired content, but a URL such as http://servername.com/example will result in a "file not found" error.

The following Alias, on the other hand, will work for both cases:

Alias /example /home/www/example

According to this document, its DNS... cos I don use alias... but how so in DNS..please advise

JimBass 06-07-2005 10:20 PM

DNS isn't where the problem is. DNS only tells the IP address of the domain itself. Unless you are part of a huge project, http://example.com/directory is going to be on the same machine and same IP address as just http://example.com. You SHOULD use an alias if you want a site to work with both http://example.com/directory/ and http://example.com/directory.

Peace,
JimBass


All times are GMT -5. The time now is 05:22 AM.