我有这个.htaccess:
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1
我在NGINX中尝试过: index工作正常,其他页面返回404错误
location /ws_php/modulos/12-projeto-final/ {
try_files $uri $uri/ /index.php/?url=$1;
}
构建我的网址 /12-projeto-final/index.php:
<?php
require(REQUIRE_PATH . '/inc/header.inc.php');
$url = ( isset($_GET['url']) ? strip_tags(trim($_GET['url'])) : 'index');
$url = explode('/', $url);
$url[0] = ($url[0] == null ? 'index' : $url[0]);
$url[1] = ( empty($url[1]) ? null : $url[1]); //EVITA NOCICE
//var_dump($url);
if (file_exists(REQUIRE_PATH . '/' . $url[0] . '.php')) :
require_once(REQUIRE_PATH . '/' . $url[0] . '.php');
elseif (file_exists(REQUIRE_PATH . '/' . $url[0] . '/' . $url[1] . '.php')) :
require_once(REQUIRE_PATH . '/' . $url[0] . '/' . $url[1] . '.php');
else:
if (file_exists(REQUIRE_PATH . '/404.php')):
require_once(REQUIRE_PATH . '/404.php');
else:
echo "<p style=\"text-align:center; padding:50px 0;\">404 Erro - Arquivo não existe!</p>";
endif;
endif;
require(REQUIRE_PATH . '/inc/footer.inc.php');
?>