首页 > 解决方案 > 可能的 ?我可以使用.htaccess 读取“PHP -S localhost”吗?

问题描述

我可以在命令提示符中使用一些特殊文本来读取我的项目中包含服务内置的.htaccess文件吗php -S

示例:~/project> $ php -S localhost:8000 -read .htaccess在我的项目中检查$_GET['url']控制路由重定向到某个文件的变量。

可能的方式?

我的迷你项目:

project
   |- src
   |- index.php
   |- .htaccess
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
</IfModule>

<?php

$url = $_GET['url'];

if ($url == "hello") {

    // go to hello file

} else {

    // go to other file

}

?>

标签: php.htaccessweb-services

解决方案


htaccess特定于 Apache 服务器。它不适用于 PHP 内置网络服务器。


推荐阅读