0
基本上,我目前正在开发某种形式的框架,它将有一个主要的索引文件来控制显示的页面,然后我会include
文件基于使用.htaccess重写的URL,因此我的.htaccess看起来像这样。在PHP中包含一个包含文件
Options +FollowSymlinks -MultiViews
AddType "text/html; charset=UTF-8" html
AddType "text/plain; charset=UTF-8" txt
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase/
# if file not exists
RewriteCond %{REQUEST_FILENAME} !-f
# if dir not exists
RewriteCond %{REQUEST_FILENAME} !-d
# avoid 404s of missing assets in our script
RewriteCond %{REQUEST_URI} !^.*\.(jpe?g|png|gif|css|js)$ [NC]
# core framework url rewriting
RewriteRule^index.php [L]
<IfModule mod_rewrite.c>
虽然记住,我有这行RewriteRule^index.php [L]
我然后使用下列保持我的index.php
define("PAGES", $_SERVER['DOCUMENT_ROOT']."/pages");
$uri = explode("/",substr($_SERVER['REQUEST_URI'],1));
if((isset($uri[0])) && ($uri[0]!="")) {$page = $uri[0];} else {$page = "login";}
if(is_file(PAGES."/$page/$page.php")) {
include(PAGES."/$page/$page.php");
} else {
include(PAGES."/error_pages/404.php");
}
这会被视为足够安全?还是会提供某种形式的漏洞利用的能力?
这似乎很好很多CMS框架像WP运营商在类似的模式。 – anubhava
感谢您的评论,最好让其他开发者的观点 – Curtis