我试图在Heroku上部署PHP应用程序,但我遇到了一个问题。我的项目结构是这样的:
+main
+app
+view (contains all my pages)
+public_html
+ assets (contains css/js files)
-index.php
-Procfile
-composer.json
-.htaccess
index.php
<?php
// Grabs the URI and breaks it apart in case we have querystring stuff
$request_uri = explode('?', $_SERVER['REQUEST_URI'], 2);
$routes = array(
"/" => "home",
"/contact" => "contact",
"/crew-search" => "crew-search",
"/dashboard" => "dashboard",
"/documentation" => "documentation",
"/entry-list" => "entry-list",
"/gallery" => "gallery",
"/links" => "links",
"/login" => "login",
"/media" => "media",
"/results" => "results",
"/schedule" => "schedule",
"/sponsors" => "sponsors"
);
if(isset($routes[$request_uri[0]])) {
require '../app/view/'.$routes[$request_uri[0]].'.php';
} else {
header('HTTP/1.0 404 Not Found');
require '../app/view/404.php';
}
Procfile
web: vendor/bin/heroku-php-apache2 public_html/
的.htaccess
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
尝试访问所有页面时出现错误消息。奇怪的是,这在localhost上工作正常。例如:
The requested URL /documentation was not found on this server.
谢谢。
答案 0 :(得分:1)
您的htaccess文件位置错误,请尝试将其移至public_html并运行。