mod_rewrite和.htaccess 404ing在一个子目录中

enl*_*loz 0 php apache .htaccess mod-rewrite http-status-code-404

例如:

Dir结构

localhost/
 |- test/
    |- index.php
    |- .htaccess
Run Code Online (Sandbox Code Playgroud)

index.php:

 <?php
        if(isset($_GET['cmd'])){
            echo "cmd is ok";
        }
 ?>
Run Code Online (Sandbox Code Playgroud)

的.htaccess

RewriteEngine On
RewriteRule ^([^/]*)/$ /test/index.php?cmd=$1 [L]
Run Code Online (Sandbox Code Playgroud)

如果用户设置: http://localhost/test/index.php?cmd=a

输出将是: cmd is ok

那没问题!

如果用户设置,我想得到相同的结果http://localhost/test/a

应该如何设置.htaccess/mod_rewrite?

有了代码,我只得到404.

Jos*_*ber 5

RewriteRule ^([^/]+) index.php?cmd=$1 [L]
Run Code Online (Sandbox Code Playgroud)