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

时间:2016-03-19 16:35:24

标签: php apache .htaccess mod-rewrite

我试图让我的.htaccess文件将所有内容重定向到index.php并使用url参数来显示我需要的内容。

如果我输入" http://localhost/2351/515"然后它只是显示404未找到而不是使用参数重定向。

的index.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]

1 个答案:

答案 0 :(得分:-1)

试一试:

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