הוסטס - פורום אחסון האתרים הגדול בישראל

הוסטס - פורום אחסון האתרים הגדול בישראל (https://hosts.co.il/forums/index.php)
-   פורום תיכנות (https://hosts.co.il/forums/forumdisplay.php?f=14)
-   -   יצירת קובץ 404, שאלה פשוטה (https://hosts.co.il/forums/showthread.php?t=85372)

kondason 29-09-10 18:54

יצירת קובץ 404, שאלה פשוטה
 
שלום,

יש לי את הפורום TRP , אני מעוניין שאם יגיעו לכתובת שלא קיימת, זה יפנה אותם לעמוד 404 שאני אכין.
ראיתי שזה קיים, כמו פה: www.fifaclub.co.il/fsafsa או כל דבר אחר שתנסו לרשום תגיעו לאותו עמוד.

איך אני עושה את זה.

Naor 29-09-10 19:04

http://www.yourhtmlsource.com/sitema...m404error.html

Kernel 29-09-10 19:44

כתבתי פעם קוד ל-404,
הוא מכסה את כל הסיומות(php,gif,asp,png וכו').

לשימושכם.

PHP קוד:

<?php
if (strpos($_SERVER['REQUEST_URI'], 'gif') !== false) {
header('Content-type: image/png');
include(
"404.png");
} elseif (
strpos($_SERVER['REQUEST_URI'], 'asp') !== false) {
echo 
"<meta http-equiv=\"refresh\" content=\"0;url=http://www.mysite.co.il/\">";
} elseif (
strpos($_SERVER['REQUEST_URI'], 'gif') !== false) {
header('Content-type: image/png');
include(
"404.png");
} elseif (
strpos($_SERVER['REQUEST_URI'], 'png') !== false) {
header('Content-type: image/png');
include(
"404.png");
} elseif (
strpos($_SERVER['REQUEST_URI'], 'php') !== false) {
include(
"../404.php");
} elseif (
strpos($_SERVER['REQUEST_URI'], 'jpg') !== false) {
header('Content-type: image/png');
include(
"404.png");
} elseif (
strpos($_SERVER['REQUEST_URI'], 'htm') !== false) {
echo 
"<meta http-equiv=\"refresh\" content=\"0;url=http://www.mysite.co.il/\">";
}
else {
echo 
"<meta http-equiv=\"refresh\" content=\"0;url=http://www.mysite.co.il/\">";
}
?>


kondason 29-09-10 22:47

ציטוט:

נכתב במקור על ידי Kernel (פרסם 781466)
כתבתי פעם קוד ל-404,
הוא מכסה את כל הסיומות(php,gif,asp,png וכו').

לשימושכם.

PHP קוד:

<?php
if (strpos($_SERVER['REQUEST_URI'], 'gif') !== false) {
header('Content-type: image/png');
include(
"404.png");
} elseif (
strpos($_SERVER['REQUEST_URI'], 'asp') !== false) {
echo 
"<meta http-equiv=\"refresh\" content=\"0;url=http://www.mysite.co.il/\">";
} elseif (
strpos($_SERVER['REQUEST_URI'], 'gif') !== false) {
header('Content-type: image/png');
include(
"404.png");
} elseif (
strpos($_SERVER['REQUEST_URI'], 'png') !== false) {
header('Content-type: image/png');
include(
"404.png");
} elseif (
strpos($_SERVER['REQUEST_URI'], 'php') !== false) {
include(
"../404.php");
} elseif (
strpos($_SERVER['REQUEST_URI'], 'jpg') !== false) {
header('Content-type: image/png');
include(
"404.png");
} elseif (
strpos($_SERVER['REQUEST_URI'], 'htm') !== false) {
echo 
"<meta http-equiv=\"refresh\" content=\"0;url=http://www.mysite.co.il/\">";
}
else {
echo 
"<meta http-equiv=\"refresh\" content=\"0;url=http://www.mysite.co.il/\">";
}
?>


מה אני עושה איתו? מכניס אותו לאיזה קובץ?

Kernel 01-10-10 22:15

תשנה את mysite.co.il לכתובת האתר שלך, שמור את הקוד למעלה כקובץ בשם error.php בתייקיה 404

פתח את ה-htaccess ותרשום בו
קוד:

RewriteEngine On
Options +FollowSymlinks
ErrorDocument 404 /404/error.php


תשים תמונה בתייקיה בשם 404.png.

kondason 01-10-10 22:31

לא עובד... www.trp.co.il/fsafsafsaf

Kernel 01-10-10 22:41

מה השגיאה באפצ'י?

kondason 01-10-10 22:46

אין שגיאה, זה שגיאת 404 רגילה, לא התמונה עולה ולא כלום...

kondason 01-10-10 22:47

אממ מה שמוזר זה שב FF זה מפנה אותי לדף הראשי של TRP.
אבל ב IE זה מציג לי את ה 404 הרגיל.

מה זה אפאצי?

zom 04-10-10 20:40

אתה יכול לעשות את זה דרך הפאנל ניהול שלך.
ב DA יש לך למטה ב Advanced features:
Custom Error Pages
וזהו..


כל הזמנים הם GMT +2. הזמן כעת הוא 17:21.

מופעל באמצעות VBulletin גרסה 3.8.6
כל הזכויות שמורות ©
כל הזכויות שמורות לסולל יבוא ורשתות (1997) בע"מ