Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php .htaccess删除页面扩展的重写模块_Php_Apache_.htaccess - Fatal编程技术网

Php .htaccess删除页面扩展的重写模块

Php .htaccess删除页面扩展的重写模块,php,apache,.htaccess,Php,Apache,.htaccess,这是我的index.php: <?PHP // $urls="404"; // IF (ISSET( $_SERVER["REQUEST_URI"] )) { $urls=$_SERVER["REQUEST_URI"]; } // $db_hand = MySQL_CONNECT( '127.0.0.1:3306', 'root', '2000' ) OR DIE( "Error Connecting DataBase" ); $db_hand = MySQL_S

这是我的
index.php

<?PHP
//
$urls="404";
//
   IF (ISSET( $_SERVER["REQUEST_URI"] ))
   {
    $urls=$_SERVER["REQUEST_URI"];
   }
//
$db_hand = MySQL_CONNECT( '127.0.0.1:3306', 'root', '2000' ) OR DIE( "Error Connecting DataBase" );
$db_hand = MySQL_SELECT_DB( 'content', $db_hand ) OR DIE( "Error Select DataBase" );
$sele = "SELECT * FROM `dg_content` WHERE urls='".$urls."' LIMIT 1";
$sele = MySQL_QUERY( $sele ) OR DIE( "Could not execute query.." );
$cols = MySQL_NUM_ROWS( $sele );
$rows = 0;
IF ($cols<=0)
{
    $sele = "SELECT * FROM `dg_content` WHERE urls='404' LIMIT 1";
    $sele = MySQL_QUERY( $sele ) OR DIE( "Could not execute query.." );
    $cols = MySQL_NUM_ROWS( $sele );
    $rows = 0;
}
//
// ---- and etc and etc
//
}
但是当我输入
http://example.org/surakarta
在浏览器上,结果似乎是404


我错在哪里?

您应该避免使用
mysql.*
函数,因为该api已贬值。此外,您的脚本对所有人都是开放的。您应该使用or.
^/([0-9]+)/([A-Za-z0-9_-]+)$
应该以
([0-9]+)
?([0-9]+)
@Darren实际上,使用
mysqli_-
和/或PDO并不是防止SQL注入的保护措施;不是靠他们自己。使用,或PDO与will一起使用。@Fred ii-你说得对,我太笼统了:-(我的一天已经很无聊了!@Darren我知道这种感觉。这就是为什么我保留一个已经制作好的文本文件lol,不得不多次重新键入它会付出代价;-)干杯
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^/([0-9]+)/([A-Za-z0-9_-]+)$ index.php?urls=$1 [QSA,L]