2017-09-05 9 views
0

J'ai configuré mon hôte virtuel (apache2) de cette manière:production symfony question de routage

<VirtualHost *:80> 
    ServerAdmin [email protected] 
    ServerName mysite.com 
    ServerAlias www.mysite.com 
    DocumentRoot /var/www/mysite.com/public_html/web 
    <Directory /var/www/mysite.com/public_html/web> 
     Require all granted 
     AllowOverride All 
     Order Allow,Deny 
     Allow from All 
    </Directory> 
    ErrorLog ${APACHE_LOG_DIR}/error.log 
    CustomLog ${APACHE_LOG_DIR}/access.log combined 
</VirtualHost> 

Et je peux voir page d'accueil et actifs mais pas d'autres routes.

si je change racine du document à:

<VirtualHost *:80> 
    ServerAdmin [email protected] 
    ServerName mysite.com 
    ServerAlias www.mysite.com 
    DocumentRoot /var/www/mysite.com/public_html/web/app.php 
    <Directory /var/www/mysite.com/public_html/web/app.php> 
     Require all granted 
     AllowOverride All 
     Order Allow,Deny 
     Allow from All 
    </Directory> 
    ErrorLog ${APACHE_LOG_DIR}/error.log 
    CustomLog ${APACHE_LOG_DIR}/access.log combined 
</VirtualHost> 

Maintenant, je peux voir tous les itinéraires, mais pas actifs ...

Comment puis-je configurer l'hôte virtuel pour voir tous les itinéraires et les actifs?

+0

ce gonfig est sur windows? –

+0

Sous Ubuntu 16.04 –

+0

Que se passe-t-il lorsque vous essayez d'accéder à d'autres routes à l'aide de la première configuration? –

Répondre

1
<VirtualHost *:80> 
    ServerName test.io 
    DocumentRoot "your_project_path/web" 
    RewriteRule ^/?(.*) http://test.io/app.php$1 [R,L] 
    <Directory "your_project_path/web"> 
     Options Indexes FollowSymLinks MultiViews 
     AllowOverride All 
     Order Allow,Deny 
     Allow from all 
     Require all granted 
     RewriteEngine On 
     RewriteCond %{REQUEST_FILENAME} -s [OR] 
     RewriteCond %{REQUEST_FILENAME} -l [OR] 
     RewriteCond %{REQUEST_FILENAME} -d 
     RewriteRule ^.*$ - [NC,L] 
     RewriteRule ^(.*) /app.php [NC,L] 
    </Directory> 
</VirtualHost> 

vérifier également web/.htaccess

DirectoryIndex app.php 
    <IfModule mod_negotiation.c> 
      Options -MultiViews 
    </IfModule> 

    <IfModule mod_rewrite.c> 
     RewriteEngine On 
     RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$ 
     RewriteRule ^(.*) - [E=BASE:%1] 

     # Sets the HTTP_AUTHORIZATION header removed by apache 
     RewriteCond %{HTTP:Authorization} . 
     RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 
     RewriteCond %{ENV:REDIRECT_STATUS} ^$ 
     RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L] 
     RewriteCond %{REQUEST_FILENAME} -f 
     RewriteRule .? - [L] 
     RewriteRule .? %{ENV:BASE}/app_dev.php [L] 
    </IfModule> 

    <IfModule !mod_rewrite.c> 
     <IfModule mod_alias.c> 
       RedirectMatch 302 ^/$ /app.php/ 
       # RedirectTemp cannot be used instead 
     </IfModule> 
    </IfModule> 

document Asper Configuring a Web Server

décharges également tous les axes routiers apache en utilisant ce commentaire application php/routeur de la console: vidage-apache

+0

Merci J'ai utilisé l'hôte virtuel (le second) dans ce tutoriel: Configuration d'un serveur Web. Maintenant ça marche! –