.htaccess重写mod用于删除页面扩展名

时间:2014-06-11 02:17:10

标签: 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_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
//
}

这是我的.htaccess:

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]

但是当我在浏览器上输入http://example.org/surakarta时,结果似乎是404。

我哪里错了?

0 个答案:

没有答案