06. december 2003 - 20:56Der er
4 kommentarer og 2 løsninger
80.63.96.228/david - virker ik men 80.63.96.228/david/ virker?
Hvordan gør jeg sådan at man ikke behøver den sidste "/" i denne adresse: 80.63.96.228/david/ for at se siden.. Den kan slet ikke finde siden når man ikke skriver den sidste "/" - Jeg har set, på mange andre servere, hvor man ikke behøver at skrive den sidste "/" - Jeg kører Win XP - Apache.. Hvad gør jeg ?
Description: Every webmaster can sing a song about the problem of the trailing slash on URLs referencing directories. If they are missing, the server dumps an error, because if you say /~quux/foo instead of /~quux/foo/ then the server searches for a file named foo. And because this file is a directory it complains. Actually is tries to fix it themself in most of the cases, but sometimes this mechanism need to be emulated by you. For instance after you have done a lot of complicated URL rewritings to CGI scripts etc. Solution: The solution to this subtle problem is to let the server add the trailing slash automatically. To do this correctly we have to use an external redirect, so the browser correctly requests subsequent images etc. If we only did a internal rewrite, this would only work for the directory page, but would go wrong when any images are included into this page with relative URLs, because the browser would request an in-lined object. For instance, a request for image.gif in /~quux/foo/index.html would become /~quux/image.gif without the external redirect!
So, to do this trick we write: ----------------------------------------- | RewriteEngine on | RewriteBase /~quux/ | RewriteRule ^foo$ foo/ [R] -----------------------------------------
The crazy and lazy can even do the following in the top-level .htaccess file of their homedir. But notice that this creates some processing overhead.
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.