typo3 404 Error redirection/mod_rewrite

Silvia

Mitglied
Alle Seiten, die eigentlich nicht mehr existieren werden im typo3 immer auf die Startseite weitergeleitet. Wir möchten, dass alles auf eine entsprechende Fehler url weitergeleitet wird.

Es lässt sich nicht über die .htaccess
ändern, da erst einmal alle Dateinamen möglich sind. Diese Namen werden dann
an die Extension AliasPro übergeben und entsprechend der Einträge in der
Datenbank umgesetzt. Wir suchen jetzt im Code gerade die Stelle wo man
einstellen kann was passieren soll wenn kein entsprechender Eintrag in der Datenbank gefunden wird, sprich ein 404 Error vorliegt. Zurzeit springt er da zur Startseite.

Meiner Meinung nach funktioniert diese Extension in Verbindung mit dem
Erweiterten Alias den wir einsetzen leider nicht, er arbeitet auch mit der
.htaccess Einstellung Errordocument.

Ich habe gestern auch schon versucht im typo3 faq was zu finden
http://typo3.org/documentation/document-li...r_404_handling/

Auch das geht nicht, da ja mod_rewrite vorliegt.
Wer kann helfen?
 
Hi Silvia,
Schön, dich auch wieder einmal hier zu sehen.
Typo arbeitet mit einem Apache Server (ja, auch unter Windows).

Da musst du folgendes tun:

Check it out
First off before you do anything else you should make sure that customising error codes in this way is allowed or even possible. Some webhosts (including most of the popular free ones I would imagine) will not permit this sort of tampering because it might mess something else important up. This is generally thought of as an “advanced” modification. Find an FAQ or email the people in charge of your server and ask if you can set it up. If you have your own domain, you shouldn’t have any restrictions of this kind.

The .htaccess file
This is the special file that sets up the deal for you. It can contain all sorts of directives for the Apache server. If you’re not using an Apache-based server, you’ll have to read your server’s manual on how to do it.

Look in your root directory, the place where your homepage is, for this file (.htaccess). If it's not there don't fret, you can just create it afresh and it won't make any difference. When doing so, just make an empty text file in Notepad or whatever, and make sure you start the filename with a dot — it's vital. This means that it is no longer a text file — the file suffix will be .htaccess, so it doesn't have a filename of its own.

sourcetip: You may have problems creating a filename that starts with a dot. If your operating system won’t let you, rename the file through your FTP program once it's online. A filename starting with a dot is how files are hidden in Unix.

Edit it
Now you need to point this file to your custom page. Add this line to the .htaccess file (edit it with a text editor like Notepad):

ErrorDocument 404 http://www.example.com/404page.html

Make sure it's all on one line, and change that address to the full address of your newly created page.

You can also give the address of the 404 page without your domain name. Simply start it with a slash, which tells the server to start looking in your root directory (where your homepage is), and follow the path you specify. For example,

ErrorDocument 404 /misc/404page.html

This will load the file 404page.html in your misc directory.

Now upload your .htaccess file to your root directory, and your 404 page to the address you specified, and you’re ready.

Then let’s turn it on!
This step may not be necessary, but if you’re unlucky you’ll have to tell your server to activate this feature. On a UNIX server, this may already be on, but if not you’ll have to telnet into your server and type chmod 644 .htaccess at the prompt. You can do this through the interface in most FTP programs too. This sets the file permissions. If you have no idea what that meant, contact your server guys again and ask them to sort it out for you.

What should I use it for?
A good 404 error page must have a number of things to be truly useful — it’s not much good simply putting up a message saying “we apologise for messing up so very horribly.”

Your 404 page should look similar to the rest of your website, so that visitors know that they’re still on part of your site.
Explain the error that has occured, and perhaps describe common reasons for the error (mistyped URLs, outdated content etc.). Use clear language and don’t ramble. Since it’s such a well-known error code, including the number “404” in this summary will get the message across quickly.
If your site has a search function, include a search box.
If you have an index, add a link to it, and definitely link back to your homepage.
Include an email link so that visitors can report the problem. Don’t expect a lot of them to take the time to do it, but some will, and it again enforces the point that you care that they’ve had a problem.
Overall, just make sure you motivate your reader not to lose all faith in your site, and give them options as to where to go next.

sourcetip: Since your 404 page might be served up from any subdirectory of your site, make sure all links and image sources are defined absolutely. For instance, use href="/index.html" instead of href="../../index.html".

Even if you don’t allow many links to go broken throughout your own site, mistakes will occur. Visitors will mistype an address, or follow a mistyped link from another site.

Studies have shown that if you recover well from an error by serving a useful error page, visitors are actually happier with their experience with a website than they would’ve been if nothing went wrong. Don’t ask me how exactly that works, but I saw it in a book, so there you go.

sourcetip: Internet Explorer has a lightly-documented “feature” that stops it from serving any custom 404 error page that is less than 512 bytes long. Your visitors will instead be sent to IE’s own 404 page (screenshot), which is generic and suggests they use an MSN search to “look for information on the Internet.” That’s one way to lose visitors! Make sure your custom 404 error page is over this limit — about 10 full lines of text and HTML should be enough.


--------------------------------------------------------------------------------

To test your work, try getting to a page you know doesn't exist and seeing if your error page comes up. Good luck.



Cheers
René
 
Hallo Rene,

Danke nochmal für Deinen Feedback. Leider hat das nichts mit .htaccess zu tun, da alle Seite egal ob sie existieren oder nicht an das CMS (typo3) weitergeleitet werden. Es
gibt also keine Seiten die nicht existieren. Das ganze wird durch folgenden
Eintrag in der .htaccess erledigt:

RewriteEngine on
RewriteRule
^(fileadmin|media|misc|t3lib|tslib|typo3|typo3conf|typo3temp|uploads)/
%{REQUEST_FILENAME} [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.php

Das wird benötigt um die Extension AliasPro überhaupt nutzen zu können. Ich
brauche eine Lösung die die Extension AliasPro betrifft bzw. den Typo3 Core.

Ich glaube aber nicht, dass wir in irgendeinem Forum dazu wirklich Auskunft
erhalten. Dieses Problem ist einfach zu speziell.

Oder hast Du eine Idee?


 
Hallo Silvia,

einfach die letzen beiden Zeilen auskommentieren, ich vermute die letzen beiden Zeilen sind hauptsächlich für das Problem verantwortlich. Die vorherige Regel könnte man noch herausnehmen, wenn man dies möchte, kann auch gleich alles auskommentiert werden. Vorausgesetzt die "RewriteEngine" muss nicht noch explizit für anderen Regeln angeschaltet werden.


Beispiel:
CODE RewriteEngine on
RewriteRule ^(fileadmin|media|misc|t3lib|tslib|typo3|typo3conf|typo3temp|uploads)/ %{REQUEST_FILENAME} [L]
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteRule .* index.php




MfG Sascha Ahlers
 
QUOTE (Silvia @ Do 19.1.2006, 23:32) Hallo Sascha,

Leider passiert gar nichts, keine Aenderung. Mache ich etwas falsch?

Hmm, was wurde den nun verändert? Und was bedeutet "es passiert gar nichts"?


Ist das die komplette .htaccess Datei? - Wenn ja, kann der Code vermutlich ganz weichen und stattdessen müssen halt die Fehlerdokumente eingetragen werden:


CODE # absolute Pfadangabe mit Nennung der Domain
ErrorDocument 401 http://www.example.com/401_unauthorized.html

# absolute Pfadangabe ohne Nennung der Domain
ErrorDocument 403 /403_forbidden.html
ErrorDocument 404 /404_not_found.html




MfG Sascha Ahlers
 
Zurück
Oben