php .htaccess 显示 404 而不是重定向


php .htaccess shows 404 instead of redirecting

我正在尝试让我的.htaccess文件将所有内容重定向到索引.php并使用url参数来显示我需要它的内容。

如果我输入类似"http://localhost/2351/515"的内容,那么它只会显示未找到 404,而不是使用参数重定向。

索引.php

<?php
    if (isset($_GET['params'])) {
        $params = explode( "/", $_GET['params'] );
        print_r($params);
        exit("YUP!");
    }
?>

.htaccess

ServerSignature Off
Options -Indexes
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.*)$ index.php?p=$1 [NC]

试试看:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php