다음은 내 .htaccess
파일입니다. default_rewrite.php
파일이 있고 내가 만든 데이터베이스에서 내 콘텐츠를 가져옵니다. 당신이 알고있는 깨진 링크 예컨대 http://www.example.com/test/fgdhfuis
에 갈 때.htaccess 파일에 오류 페이지를 추가하는 방법
RewriteEngine on
RewriteRule ^/?([a-z0-9-_]*)$ default-rewrite.php?page=$1 [L]
는 내 기본 재 작성 페이지로 이동하지만 데이터베이스에 저장된 페이지로 이동하지 않습니다. 예컨대
http://www.example.com/test/home
나는 ErrorDocument 404 /404.php
시도했지만이 나를 위해 그것을하지 않습니다.
모든 조언을 크게 듣습니다. PHP를 편집 아래
:<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$colname_Page = "home";
if (isset($_GET['page'])) {
$colname_Page = $_GET['page'];
if($colname_Page == "")
$colname_Page = "home";
}
mysql_select_db($database_VRMOnline, $VRMOnline);
$query_Page = sprintf("SELECT * FROM Page WHERE PageName = %s", GetSQLValueString($colname_Page, "text"));
$Page = mysql_query($query_Page, $VRMOnline) or die(mysql_error());
$row_Page = mysql_fetch_assoc($Page);
$totalRows_Page = mysql_num_rows($Page);
mysql_select_db($database_VRMOnline, $VRMOnline);
$query_MetaData = "SELECT * FROM MetaData WHERE MetaDataID = 1";
$MetaData = mysql_query($query_MetaData, $VRMOnline) or die(mysql_error());
$row_MetaData = mysql_fetch_assoc($MetaData);
$totalRows_MetaData = mysql_num_rows($MetaData);
?>
내가
$colname_Page = "home";
if (isset($_GET['page'])) {
$colname_Page = $_GET['page'];
if($colname_Page == "")
$colname_Page = "home";
if ($totalRows_Page == 0)
{
$colname_Page = "404-error";
}
을 시도하지만이 모든 페이지가
데이터베이스를 검사하는 코드 스 니펫을 가져올 수 있습니까? 귀하의 재 작성 규칙 이후, 모든 URL을 default-rewrite.php로 다시 작성합니다. 문제는 코드에 있습니다. – ku6pk
그래서 기본 재 작성 페이지로 이동하여 데이터베이스의 페이지를 추가합니다. –
$ colname_Page가 데이터베이스에 있는지 확인하는 코드가 있어야합니다. – ku6pk