2017-05-04 99 views
0

我有我的symfony应用程序在生产环境,但我不明白为什么它不运行没有app.php。例如,如果我使用mydomainname,我可以看到主页,但是其他路由在404错误中找不到,但是如果我使用app.php(mydomainname/app.php/register)对其他路由进行了数字化,它可以完美运行。 我的httpd.conf是:Symfony的网址没有app.php

ServerRoot "/etc/httpd" 

Listen 80 

LoadModule rewrite_module modules/mod_rewrite.so 

Include conf.modules.d/*.conf 

User myuser 
Group psacln 

ServerName mydomainname:80 

<Directory /> 
    AllowOverride none 
    Require all denied 
</Directory> 

DocumentRoot "/var/www/vhosts/myexample.com/httpdocs/web" 

<Directory "/var/www"> 
    AllowOverride None 
    # Allow open access: 
    Require all granted 
</Directory> 

<Files ".ht*"> 
    Require all denied 
</Files> 

ErrorLog "logs/error_log" 

LogLevel warn 

<IfModule log_config_module> 
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined 
    LogFormat "%h %l %u %t \"%r\" %>s %b" common 

    <IfModule logio_module> 
     LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio 
    </IfModule> 

    CustomLog "logs/access_log" combined 
</IfModule> 

<IfModule alias_module> 
    ScriptAlias /cgi-bin/ "/var/www/cgi-bin/" 

</IfModule> 

<Directory "/var/www/cgi-bin"> 
    AllowOverride None 
    Options None 
    Require all granted 
</Directory> 

<IfModule mime_module> 
    TypesConfig /etc/mime.types 

    AddType application/x-compress .Z 
    AddType application/x-gzip .gz .tgz 

    AddType text/html .shtml 
    AddOutputFilter INCLUDES .shtml 
</IfModule> 


<IfModule mime_magic_module> 
    MIMEMagicFile conf/magic 
</IfModule> 

EnableSendfile on 

IncludeOptional conf.d/*.conf 
GracefulShutDownTimeout 3 
AddOutputFilter INCLUDES .shtml 
AddType text/html .shtml 
AddType application/x-httpd-php .php 
AddType application/x-httpd-php-source .phps 

<VirtualHost *:80> 

     CustomLog /var/log/httpd/myexample.com-access.log combined 
    ErrorLog /var/log/httpd/myexample.com-error.log 
     ServerName myexample.com 
    ServerAlias mydomainname 
     DocumentRoot /var/www/vhosts/myexample.com/httpdocs/web 
    <Directory /var/www/vhosts/myexample.com/httpdocs/web> 
       DirectoryIndex app.php 

     AllowOverride None 
       Order Allow,Deny 
       Allow from All 
      <IfModule mod_rewrite.c> 
        Options -MultiViews 
        RewriteEngine On 
        RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f 
        RewriteRule^/app.php [L] 
      </IfModule> 

    </Directory>  
</VirtualHost> 

会在error_log文件我对路径登记例如:

[Tue May 02 16:45:55.666829 2017] [rewrite:trace3] [pid 29165:tid 140058380187392] mod_rewrite.c(470): [client 132.64.127.101:54785] 132.64.127.101 - - [mydomainname/sid#7f6204b70c60][rid#7f61d4006440/initial] applying pattern '^(.*)$' to uri '/register/', referer: h t t p s : //mydomainname/ 
[Tue May 02 16:45:55.666870 2017] [rewrite:trace4] [pid 29165:tid 140058380187392] mod_rewrite.c(470): [client 132.64.127.101:54785] 132.64.127.101 - - [mydomainname/sid#7f6204b70c60][rid#7f61d4006440/initial] RewriteCond: input='mydomainname' pattern='^mydomain\\.com$' [NC] => not-matched, referer: h t t p s : //mydomainname/ 
[Tue May 02 16:45:55.666886 2017] [rewrite:trace1] [pid 29165:tid 140058380187392] mod_rewrite.c(470): [client 132.64.127.101:54785] 132.64.127.101 - - [mydomainname/sid#7f6204b70c60][rid#7f61d4006440/initial] pass through /register/, referer: h t t p s : //mydomainname/ 
[Tue May 02 16:45:55.670388 2017] [rewrite:trace2] [pid 29165:tid 140058380187392] mod_rewrite.c(470): [client 132.64.127.101:54785] 132.64.127.101 - - [mydomainname/sid#7f6204b70c60][rid#7f61d401c1a0/initial/redir#1] init rewrite engine with requested uri /error_docs/not_found.html, referer: h t t p s : //mydomainname/ 
[Tue May 02 16:45:55.670403 2017] [rewrite:trace3] [pid 29165:tid 140058380187392] mod_rewrite.c(470): [client 132.64.127.101:54785] 132.64.127.101 - - [mydomainname/sid#7f6204b70c60][rid#7f61d401c1a0/initial/redir#1] applying pattern '^(.*)$' to uri '/error_docs/not_found.html', referer: h t t p s:// mydomainname/ 
[Tue May 02 16:45:55.670410 2017] [rewrite:trace4] [pid 29165:tid 140058380187392] mod_rewrite.c(470): [client 132.64.127.101:54785] 132.64.127.101 - - [mydomainname/sid#7f6204b70c60][rid#7f61d401c1a0/initial/redir#1] RewriteCond: input='mydomainname' pattern='^mydomain\\.com$' [NC] => not-matched, referer: https://mydomainname/ 
[Tue May 02 16:45:55.670414 2017] [rewrite:trace1] [pid 29165:tid 140058380187392] mod_rewrite.c(470): [client 132.64.127.101:54785] 132.64.127.101 - - [mydomainname/sid#7f6204b70c60][rid#7f61d401c1a0/initial/redir#1] pass through /error_docs/not_found.html, referer: https://mydomainname/ 

mod_rewrite的是,因为如果我运行的httpd -M命令存在行:

rewrite_module(共享)

我的服务器是:

服务器版本:Apache/2.4.6(CentOS)

我能做些什么来解决它?

非常感谢。

+0

任何人都可以帮助我吗?我只需要指示 – Massimiliano

回答

1

@Massimiliano

我曾经有同样的问题。我通过在web文件夹中添加.htaccess文件进行纠正。

尝试在.htaccess文件
<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ app.php/$1 [QSA,L] </IfModule>

REFERENCE LINK HERE添加此。

和这样的虚拟主机。

<VirtualHost *:80> DocumentRoot /var/www/html/symfony_site/web DirectoryIndex app.php <Directory /var/www/html/symfony_site/web > AllowOverride All Allow from All </Directory> </VirtualHost>

例如,如果我用mydomainname可以看我的主页,但其他路线错误404去没有找到,但如果我的数字,例如其他途径使用app.php
=>添加.htaccess文件,问题将被纠正。