如何在没有此文件夹结构的情况下运行symfony项目

时间:2017-01-31 10:59:07

标签: symfony

每当我尝试运行我的项目时,我只得到文件夹结构。为什么?

/ my_project的索引

Parent Directory             
README.md
bin/ 
composer.json        
composer.lock   
vendor/  
web/ 

localhost端口80上的Apache / 2.4.7(Ubuntu)服务器

1 个答案:

答案 0 :(得分:0)

您需要配置 .htaccess httpd.conf 才能访问网络文件夹

解决方案#1:

使用 DocumentRoot 文件夹中的以下文件内容创建 .htaccess 文件(基本上是您看到此文件夹结构的位置)

Options +FollowSymLinks +ExecCGI

  RewriteEngine On

  # uncomment the following line, if you are having trouble
  # getting no_script_name to work
  RewriteBase /web

  # we skip all files with .something
  RewriteCond %{REQUEST_URI} \..+$
  RewriteCond %{REQUEST_URI} !\.html$
  RewriteRule .* - [L]

  # we check if the .html version is here (caching)
  RewriteRule ^$ app.php [QSA]
  RewriteRule ^([^.]+)$ $1.html [QSA]
  RewriteCond %{REQUEST_FILENAME} !-f

  # no, so we redirect to our front web controller
  RewriteRule ^(.*)$ index.php [QSA,L]

解决方案#2:

您还可以根据您的网络托管服务提供商调整 httpd.conf ,如果是这样的话,我会在symfony上查阅此页面:http://symfony.com/doc/current/setup/web_server_configuration.html

<强>更新 如果问题已经回答,请将此问题标记为已回答

相关问题