Php 未找到404的Htaccess-Modrewrite验证

Php 未找到404的Htaccess-Modrewrite验证,php,.htaccess,Php,.htaccess,找不到404,如何进行压缩 这是我的php代码: $id = $_GET['id']; $slug = "my-slugified-title-post-in-this-example"; // Slug is dinamic according to id echo "This post is here!"; 这是我的访问权限 RewriteRule ^posts/([0-9]+)/(.*?).html post.php?id=$1$slug=$2 [L,NC] 如果url中的$slug

找不到404,如何进行压缩

这是我的php代码:

$id = $_GET['id'];
$slug = "my-slugified-title-post-in-this-example"; // Slug is dinamic according to id

echo "This post is here!";
这是我的访问权限

RewriteRule ^posts/([0-9]+)/(.*?).html post.php?id=$1$slug=$2 [L,NC]
如果url中的$slug错误,我希望404错误:

http://mysite.com/posts/274/my-slugified-title-post-wrong-in-this-example.html //slug is wrong
这没关系

http://mysite.com/posts/274/my-slugified-title-post-in-this-example.html

如果slug是错误的,您必须将其与从id中提取的slug进行比较。因此,在php脚本中,您将有如下内容:

$id = $_GET['id'];
$slug = "my-slugified-title-post-in-this-example"; // Slug is dinamic according to id

if ( $slug != $_GET['slug'] ) {   // slug is different
    header('HTTP/1.0 404 Not Found');
    exit();
}

echo "This post is here!";

如果slug是错误的,您必须将其与从id中提取的slug进行比较。因此,在php脚本中,您将有如下内容:

$id = $_GET['id'];
$slug = "my-slugified-title-post-in-this-example"; // Slug is dinamic according to id

if ( $slug != $_GET['slug'] ) {   // slug is different
    header('HTTP/1.0 404 Not Found');
    exit();
}

echo "This post is here!";