2017-07-22 2 views
0

Ich habe eine Website mit Symfony 2.8.22 mit Apache 2.4.18 ausgeführt. Ich habe RewriteEngine im virtuellen Host aktiviert, um die .php-Erweiterung in der URL nicht anzuzeigen. Ich habe jedoch 2 Probleme. Die erste ist, dass ich die .php-Erweiterung über die URL bekomme. Das zweite Problem ist, dass ich eine Schleife auf der Anmeldeseite habe; Sobald ich die Zugangsdaten eingegeben habe, wird die Anmeldeseite erneut und wieder geladen. Das passiert in Chrome und Firefox, aber in Microsoft Edge wird diese Schleife nicht passieren, es folgt nur auf die nächste Seite.Symfony App show .php Erweiterung in URL und Loop Login-Seite

Warum ist das?

Wo ist meine Virtualhost-Datei:

<VirtualHost *:80> 
    ServerName ip.ip.ip.ip 

    DocumentRoot /var/www/html/website/web 
    <Directory /var/www/html/website/web> 
     AllowOverride All 
     Order Allow,Deny 
     Allow from All 

    <IfModule mod_rewrite.c> 
     Options -MultiViews 
     RewriteEngine On 
     RewriteRule (.*)\.php $1 [R=301,L] 
    </IfModule> 
    </Directory> 

    <Directory /var/www/project> 
     Options FollowSymlinks 
    </Directory> 

    ErrorLog /var/log/apache2/error_website.log 
    CustomLog /var/log/apache2/access_website.log combined 
</VirtualHost> 

Vielen Dank im Voraus.

Mit freundlichen Grüßen.

Antwort

0

Ich bin nicht sicher, warum Sie versuchen, .php aus der Web-Adressleiste zu entfernen. Wenn Sie die Symfony Configuration guide folgen wird es Ihnen eine .htaccess-Datei geben, die funktioniert und wird nicht angezeigt .php Erweiterungen:

<VirtualHost *:80> 
    ServerName domain.tld 
    ServerAlias www.domain.tld 

    DocumentRoot /var/www/project/web 
    <Directory /var/www/project/web> 
     AllowOverride None 
     Order Allow,Deny 
     Allow from All 

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

    # uncomment the following lines if you install assets as symlinks 
    # or run into problems when compiling LESS/Sass/CoffeeScript assets 
    # <Directory /var/www/project> 
    #  Options FollowSymlinks 
    # </Directory> 

    # optionally disable the RewriteEngine for the asset directories 
    # which will allow apache to simply reply with a 404 when files are 
    # not found instead of passing the request into the full symfony stack 
    <Directory /var/www/project/web/bundles> 
     <IfModule mod_rewrite.c> 
      RewriteEngine Off 
     </IfModule> 
    </Directory> 
    ErrorLog /var/log/apache2/project_error.log 
    CustomLog /var/log/apache2/project_access.log combined 
</VirtualHost>