php - 可能的 ?我可以使用.htaccess 读取“PHP -S localhost”吗?
问题描述
我可以在命令提示符中使用一些特殊文本来读取我的项目中包含服务内置的.htaccess
文件吗php -S
示例:~/project> $ php -S localhost:8000 -read .htaccess
在我的项目中检查$_GET['url']
控制路由重定向到某个文件的变量。
可能的方式?
我的迷你项目:
- 这是我的项目目录
project
|- src
|- index.php
|- .htaccess
- 文件中的代码
.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>
- 文件中的代码
index.php
:
<?php
$url = $_GET['url'];
if ($url == "hello") {
// go to hello file
} else {
// go to other file
}
?>
解决方案
htaccess
特定于 Apache 服务器。它不适用于 PHP 内置网络服务器。
推荐阅读
- javascript - 来自现有 div 的 javascript 数组
- shell - 如何在基于 unix 的命令行上检查 tail 到多个文件的输出字符串是否相等?
- python - 以 10 为底的 int() 的 sqlalchemy 无效文字
- python - Python从特定角色获取所有成员列表
- java - 使用 Regex 从进程命令行捕获 Java 程序名称/包名称
- opencv - 如何从 opencv 中支持的网络摄像头获得超过 30FPS?
- c# - 当我更改 asp.net 页面的前景色时,它会影响其他页面的前景色
- python - 读取文件夹中存在的所有文件时出错
- database - 火花流能够为每个批次将数据存储在数据库中吗?
- c - Print the occurences of digit 4. - CodeChef