2016-08-01 5 views
0

Zusammenfassung:Symfony2.8.x: Wie konfiguriere ich Apache, um "web/app.php" von meiner URL zu entfernen?

  1. my-host-here.com/app_dev.php/main = arbeitet

  2. my-host-here.com/main = 404 Fehler

  3. my- host-here.com/app.php/main = bekommt auch einen 404-Fehler

ich an verschiedenen Links haben gesucht (symfony.com und hier Diskussionen in SO) und versuchten, ihre Vorschläge/answ aber kein Glück hier.

Irgendwelche Ideen, wie man es beheben kann? Danke vielmals!

Ich verwende Apache 2.4.x/PHP 5.4.x, die mit dem yum-Repository auf RHEL7 installiert wurden.

Schnipsel httpd.conf

Include conf.modules.d/*.conf 

Schnipsel 00-base.conf die

LoadModule reqtimeout_module modules/mod_reqtimeout.so 
LoadModule rewrite_module modules/mod_rewrite.so 
LoadModule setenvif_module modules/mod_setenvif.so 
LoadModule slotmem_plain_module modules/mod_slotmem_plain.so 

Schnipsel von 10-php.conf innen conf.modules.d residiert die sich in conf.modules.d befindet

LoadModule php5_module modules/libphp5.so 

Schnipsel meiner Virtualkonfigurationsdatei

<VirtualHost *:80> 
ServerName my-host-here.com 
DocumentRoot /opt/www/my-host-here/web 

<Directory /opt/www/my-host-here/web/> 
    DirectoryIndex app.php 
    AllowOverride All 
    Require all granted 

<IfModule mod_rewrite.c> 
    Options -MultiViews 
    RewriteEngine On 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteRule ^(.*)$ app.php [QSA,L] 
</IfModule> 
</Directory> 

Den Inhalt der .htaccess innen/opt/www/my-host-hier/Bahn, was Symfony mit kam. Ich habe es nie geändert. Symfony Projekt wurde mit dem Befehl erstellt:

symfony new my_project_name lts 
+0

https://github.com/sym fony/symfony-standard/blob/master/web/.htaccess – zerkms

+0

@zerkms Ich schaute auf approot/web/und es scheint, dass ich genau die gleiche Datei schon habe. – mrjayviper

+0

ist mod_rewrite in Apache2 aktiviert? Symfony enthält standardmäßig die korrekte .htaccess-Datei, Sie sollten also nichts dafür tun. siehe http://stackoverflow.com/questions/9021425/how-to-check-if-mod-rewrite-is-enabled-in-php – NDM

Antwort

1

Hier ist meine Einstellungen:

/etc/apache2/sites-available/project.conf

<VirtualHost *:80> 
    ServerName project  
    DocumentRoot /path/to/project/web 

    <Directory /path/to/project/web > 
     Options Indexes FollowSymlinks 
     AllowOverride All 
     Require all granted 
    </Directory> 

    ErrorLog /path/to/project/error.log 
    CustomLog /path/to/project/access.log combined 
    </VirtualHost> 

web/.htaccess

<IfModule mod_rewrite.c> 
    Options +FollowSymlinks 
    RewriteEngine On 

    # Explicitly disable rewriting for front controllers 
    # RewriteRule ^app.php - [L] 
    RewriteRule ^app_dev.php - [L] 

    RewriteCond %{REQUEST_FILENAME} !-f 

    # Change below before deploying to production 
    # RewriteRule ^(.*)$ app.php [QSA,L] 
    RewriteRule ^(.*)$ app_dev.php [QSA,L] 
</IfModule>