简体   繁体   English

如何在PHP Composer中将用户重定向到public /目录?

[英]How to redirect user to public/ directory in PHP Composer?

This is how my file structure is: 这是我的文件结构:

./ git
./ public
      ./assets/
      ./pages/
      ./index.php
./tests
./vendor
./composer.json
./composer.lock

./index.php ==> header('Location: /public/'); ./index.php ==> header('Location:/ public /'); Should I do this ? 我应该这样做吗?

Instead of typing stories.com/public in my browser eveytime, should I include an index.php and then use header call or is there any other * better * method ? 而不是在浏览器eveytime中键入stories.com/public ,我应该包含index.php然后使用标头调用,还是有其他*更好*的方法?

Please keep in mind I want to later on deploy my app to HEROKU for FREE 请记住,我想稍后将我的应用免费部署到HEROKU

You should just set the document root folder to be your public folder. 你应该只设置文档的根文件夹是您的public文件夹。

This is from the FAQ: https://devcenter.heroku.com/articles/custom-php-settings#setting-the-document-root 这是从FAQ中获得的: https : //devcenter.heroku.com/articles/custom-php-settings#setting-the-document-root

For example, if you're using Apache with PHP, and you'd like your document root to be set to the public sub-directory of your application (because that's where your index.php and all images, CSS and JavaScript reside), your Procfile would look like this: 例如,如果您将Apache与PHP一起使用,并且希望将文档根目录设置为应用程序的公共子目录(因为那是您的index.php以及所有图像,CSS和JavaScript所在的位置),您的Procfile看起来像这样:

web: vendor/bin/heroku-php-apache2 public/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM