2017-05-04 97 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文件,問題將被糾正。