PDA

Bekijk Volledige Versie : Hoe kom ik van die slash af?



www.raph.nl
13/02/03, 00:05
Dag NIWSS,

Ik zit met een klein probleempje:
als ik intyp http://www.raph.nl/toegankelijkheid/, dan krijg ik de
pagina die ik wil hebben. Vrij logisch allemaal. Maar als ik intyp:
http://www.raph.nl/toegankelijkheid, dan gaat het niet goed en krijg
ik een mededeling "Error: 301 Moved Permanently". In Mozilla althans,
want in IE krijg je "Kan de server niet vinden of DNS-fout".
Nu is mijn vraag: is dit op te lossen met een regeltje in de .htaccess
file? En zo ja, wat is dan de tekst van dat regeltje?


m.vr.gr.

Raph
www.raph.nl

Jan Ehrhardt
13/02/03, 00:05
www.raph.nl in nl.internet.www.server-side (Wed, 12 Feb 2003 23:56:49
+0100):

>Ik zit met een klein probleempje:
>als ik intyp http://www.raph.nl/toegankelijkheid/, dan krijg ik de
>pagina die ik wil hebben. Vrij logisch allemaal. Maar als ik intyp:
>http://www.raph.nl/toegankelijkheid, dan gaat het niet goed en krijg
>ik een mededeling "Error: 301 Moved Permanently". In Mozilla althans,
>want in IE krijg je "Kan de server niet vinden of DNS-fout".
>Nu is mijn vraag: is dit op te lossen met een regeltje in de .htaccess
>file? En zo ja, wat is dan de tekst van dat regeltje?

Er worden hele verhalen geschreven over mod_rewrite met die slash. Maar het
simpelste is

Redirect Permanent /toegankelijkheid http://www.raph.nl/toegankelijkheid/

in je .htaccess

Jan
--
Dropdown and pushup menu's - http://cgi.monitor.nl/cms.html

Rene Pijlman
13/02/03, 00:45
www.raph.nl:
>als ik intyp http://www.raph.nl/toegankelijkheid/, dan krijg ik de
>pagina die ik wil hebben. Vrij logisch allemaal. Maar als ik intyp:
>http://www.raph.nl/toegankelijkheid, dan gaat het niet goed en krijg
>ik een mededeling "Error: 301 Moved Permanently".

Dit zou kunnen wijzen op het ontbreken van een ServerName in de
sitedefinitie in httpd.conf, of op een probleem met een Alias.

"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
"
http://httpd.apache.org/docs/misc/FAQ.html#set-servername

--
René Pijlman

Wat wil jij leren? http://www.leren.nl

www.raph.nl
16/02/03, 19:35
"www.raph.nl" <raph@dds.nl> schreef in bericht
news:1045090610.530230@halkan.kabelfoon.nl...
> Dag NIWSS,
>
> Ik zit met een klein probleempje:
> als ik intyp http://www.raph.nl/toegankelijkheid/, dan krijg ik de
> pagina die ik wil hebben. Vrij logisch allemaal. Maar als ik intyp:
> http://www.raph.nl/toegankelijkheid, dan gaat het niet goed en krijg
> ik een mededeling "Error: 301 Moved Permanently". In Mozilla
althans,
> want in IE krijg je "Kan de server niet vinden of DNS-fout".
> Nu is mijn vraag: is dit op te lossen met een regeltje in de
..htaccess
> file? En zo ja, wat is dan de tekst van dat regeltje?
>
>
> m.vr.gr.
>
> Raph
> www.raph.nl
>

Jan Ehrhart en Rene Pijlman hebben me op het juiste spoor gezet; dank
daarvoor. Maar ik wilde een generieke oplossing en heb dus nog iets
verder gezocht.
In het bestand .htaccess heb ik nu de volgende regels gezet:

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+[^/])$ $1/ [R]

Dit is een generieke oplossing voor het probleem en het werkt prima,
voor zover ik heb kunnen nagaan.
Zie onder het kopje 'Trailing Slash Problem' op
http://httpd.apache.org/docs/misc/rewriteguide.html


m.vr.gr.

Raph

uws
16/02/03, 20:45
I <1045420343.7156@halkan.kabelfoon.nl>, www.raph.nl skrev:
> [http://domein/bla werkt niet, http://domain/bla/ wel]

Volgens mij moet je toch nog maar eens je apache configuratie file
doorlopen, want dit is een standaardprobleem... (tip: _alias_)

--
uws mail uws@xs4all.nl

if you really want to live :: why not try and make yourself -- incubus

www.raph.nl
16/02/03, 23:05
"uws" <uws@nospam-xs4all.nl> schreef in bericht
news:im-a-msgid-virus-20030216-194145@uwsworld.xs4all.nl...
> I <1045420343.7156@halkan.kabelfoon.nl>, www.raph.nl skrev:
> > [http://domein/bla werkt niet, http://domain/bla/ wel]
>
> Volgens mij moet je toch nog maar eens je apache configuratie file
> doorlopen, want dit is een standaardprobleem... (tip: _alias_)
>

Dag uws,

Ik heb een account waarbij je geen toegang hebt tot de Apache
configuratiefile. Dus ik moet 't wel regelen via .htaccess. Of een
andere provider nemen, uiteraard...

m.vr.gr.

Raph
www.raph.nl/toegankelijkheid <- werkt nu ook zonder slash

uws
16/02/03, 23:05
I <1045432746.821890@halkan.kabelfoon.nl>, www.raph.nl skrev:
> Ik heb een account waarbij je geen toegang hebt tot de Apache
> configuratiefile. Dus ik moet 't wel regelen via .htaccess. Of een
> andere provider nemen, uiteraard...

Of je mailt de admins daar dat er een tikfout in hun configuratie zit.

--
uws mail uws@xs4all.nl

step into my shadow :: forty-six & 2 just ahead of me -- tool

www.raph.nl
17/02/03, 12:55
uws <uws@nospam-xs4all.nl> wrote in message news:<im-a-msgid-virus-20030216-220009@uwsworld.xs4all.nl>...
> I <1045432746.821890@halkan.kabelfoon.nl>, www.raph.nl skrev:
> > Ik heb een account waarbij je geen toegang hebt tot de Apache
> > configuratiefile. Dus ik moet 't wel regelen via .htaccess. Of een
> > andere provider nemen, uiteraard...
>
> Of je mailt de admins daar dat er een tikfout in hun configuratie zit.

Zouden ze bij LaDot reageren, denk je?

m.vr.gr.

Raph

uws
17/02/03, 13:15
I <d8ffdf92.0302170352.48ce6366@posting.google.com>, www.raph.nl skrev:
> Zouden ze bij LaDot reageren, denk je?

Je moet ook niet emailen maar bellen :-p

--
uws mail uws@xs4all.nl

so i'll be your liqour demons will drown :: and float away -- placebo

www.raph.nl
17/02/03, 15:15
"uws" <uws@nospam-xs4all.nl> schreef in bericht
news:im-a-msgid-virus-20030217-120000@uwsworld.xs4all.nl...
> I <d8ffdf92.0302170352.48ce6366@posting.google.com>, www.raph.nl
skrev:
> > Zouden ze bij LaDot reageren, denk je?
>
> Je moet ook niet emailen maar bellen :-p
>
> --
> uws mail
uws@xs4all.nl

Telefoon: 0900-2266666 - 0,30 Euro/min.
Da's al gauw een duur grapje als je een kwartier in de wacht wordt
gezet.
toevoegen aan .htaccess werkt toch net zo goed, neem ik aan?

m.vr.gr.

Raph