可以通过 .htaccess 将查询发送到另一个文件吗?稍微解释一下:
index.php像这样处理所有页面:
switch($page) {
case 'index':
require_once START . '/includes/pages/index.php';
break;
case 'another':
require_once START . '/includes/pages/another.php';
break;
and so on...
在 .htaccess 中:
RewriteRule ^index$ index.php?page=index [L]
RewriteRule ^another$ index.php?page=another [L]
链接(例如localhost/84ss7d41):
RewriteRule ^(.*)$ index.php?QUERY_STRING=$1 [L]
所以在/includes/pages/index.php:
if ($_GET['QUERY_STRING']) {
$_SERVER['QUERY_STRING'] = $_GET['QUERY_STRING'];
$query_string = check_input($_SERVER['QUERY_STRING']);
//checking/validating processing further...
如何使像这样的链接localhost/84ss7d41以与现在相同的方式工作,但没有index.php?如果发生某些事情(文件被意外删除),我正在尝试分离我的“项目”,检查/验证数据的工作方式相同,没有主脚本,就像:
if (main project file index.php/ || /includes/pages/index.php doesn't exist) {
check/validate data with reserve.php
}