我已经构建了一个基于MVC架构的小型自定义框架,我有两个BASE_URL,类似于' http://example.com '和ROOT,就像'/ Applications / XAMPP / htdocs / WEBSITENAME /' 。 我试图获得一个普遍的共识,即当将其部署到服务器时哪个更好。 我确实有ssh访问它将被释放的服务器。 老实说,我不知道哪个是首选或为什么。 我做了很多谷歌搜索,发现相互矛盾的论点,所以我想我会问这里,因为我相信这个社区。 所以任何人都有关于哪个更好的想法,为什么?
哦,如果重要的是我们正在尝试使用httpd-vhost.conf来创建web目录而没有.htaccess文件,我们正在尝试删除所有mod_rewrite。 不确定这是否重要,但我想我会提供信息以防万一。
提前谢谢大家的帮助。
编辑**我想我还应该提到我并不是说我创建链接时,我的意思是包括css表,或js文件,或包括并要求其他php文件,这些类型的操作。
I have built a little custom framework that is based on MVC architecture and I have both BASE_URL which would be something like 'http://example.com' and ROOT which would be something like '/Applications/XAMPP/htdocs/WEBSITENAME/'. I am trying to get a general consensus as to which is better to use when this would be deployed to a server. I do have ssh access to the server that it would be released on. I just honestly do not know which is preferred or why. I did a lot of googling and found conflicting arguments so I thought I would ask here since I trust this community. So Anyone have thoughts on which is better and why?
Oh, if it matters we are trying to use httpd-vhost.conf to create the web directories and no .htaccess files, and we are trying to remove all mod_rewrite. Not sure if that matters, but I thought I would give the info just in case.
Thank you all for your help in advance.
EDIT** I guess I should also mention that I do not mean when I am creating links, I mean for including css sheets, or js files, or including and requiring other php files, those types of actions.
最满意答案
你有2个案例:
用于与服务器端的其他文件进行交互,而php脚本仍在执行 - 包括/要求其他php文件,开放资源等操作使用相对于ROOT的路径。
包括CSS,javascript,图像等 - 在客户端 - 你将使用BASE_URL。
例如,在PHP中:
require_once ROOT . DIRECTORY_SEPARATOR . 'my_configuration_file.php';在HTML中:
<img src="<?=BASE_URL;?>/img/logo.png" alt="my company">但考虑使用现有的PHP框架。 它将使您的生活更轻松,让您专注于您的产品/网站,而不是维护它。
You have 2 cases:
for interacting with other files on the sever's side, while the php script is still executing - operations like including / requiring other php files, fopen-ing resources and so on you use paths relative to your ROOT.
for including CSS, javascript, images and so on - on client side - you're going to use the BASE_URL.
For example, in PHP:
require_once ROOT . DIRECTORY_SEPARATOR . 'my_configuration_file.php';in the HTML:
<img src="<?=BASE_URL;?>/img/logo.png" alt="my company">But consider using an existing PHP framework. It will make your life easier and let you focus on your product / site rather than maintaing it.
更多推荐
发布评论