我正在尝试设置一个新的网站,使用Twitter bootstrap作为前端,PHP作为后台代码。
我使用的目录结构如下且相当标准
c:\xampp\htdocs\app
c:\xampp\htdocs\app\application\configs
c:\xampp\htdocs\app\application\modules
c:\xampp\htdocs\app\data\
c:\xampp\htdocs\app\data\logs
c:\xampp\htdocs\app\data\sessions
c:\xampp\htdocs\public_html\
c:\xampp\htdocs\public_html\css
c:\xampp\htdocs\public_html\js
c:\xampp\htdocs\public_html\img我的Apache配置相当简单,由以下部分组成
<VirtualHost *:80>
ServerName vinner.localhost
DocumentRoot C:/xampp/htdocs/app/public_html
SetEnv APPLICATION_ENV "development"
<Directory C:/xampp/htdocs/app/public_html>
DirectoryIndex index.php index.html index.htm \
default.php default.asp default.shtml default.html default.htm \ AllowOverride All
Order allow,deny
Allow from all
</Directory>
以前我把PHP代码放在/public_html文件夹中,但这显然不是很好的做法,所以我把它移到了c:\xampp\htdocs\app\application\modules,但是我不知道如何将POST查询直接指向PHP页面,或者创建一个通用的PHP模板/包含文件以便我的PHP页面易于访问。
发布于 2013-02-03 15:18:33
在"public_html“目录中应该有一个文件,通常称为"index.php”。然后,您的web服务器规则(例如,.htaccess或服务器配置)将所有请求(或者,所有不是针对“public_html”中存在的文件的请求)指向"public_html/index.php“。这通常是"public_html“下唯一的PHP文件,但有时可能会有多个文件用于不同的目的(例如,一个不同的文件用于提供图像)。
在那里,您可以使用相对路径包含您的其余代码,下面的每一个都是等效的(“public_html/index.php”中的代码):
include __DIR__ . '/../application/[application-code].php';和:
include dirname(__DIR__) . '/application/[application-code].php';其中“应用程序代码”是应用程序的入口点,通常命名为"bootstrap.php“。
https://stackoverflow.com/questions/14670263
复制相似问题