Apache服务器上的Symfony 3 // Postman POST请求在url中没有app.php时无效

Apache服务器上的Symfony 3 // Postman POST请求在url中没有app.php时无效

问题描述:

I have a working Symfony 3 API on an Apache Server - more info here and here these are already resolved

I am now facing a routing problem I think, my postman POST methods working fine if use a URL like: https://example.com/app.php/mcPDF/ but when I try with URL: https://example.com/mcPDF/ it says 404 not found.

I tried several answers here, like changing the htaccess IfModule mod_rewrite.c> section and added various settings in 000-default.conf file like:

<Directory /var/www/html/pdf/web>
    AllowOverride All
    Order Allow,Deny
    Allow from All
    DirectoryIndex app.php
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ app.php [QSA,L]
    </Directory>

and every time I do changes I do:

- bin/console cache:clear --env=prod --no-warmup
- bin/console cache:warmup --env=prod

and I also did the sudo a2enmod rewrite and restarted the server many times

Please advise, let me know what info you need more

All my PROD servers use configuration below and they all work fine. Try to update yours accordingly to see what happens.

# $ nano /etc/apache2/sites-available/000-default.conf

<VirtualHost *:80>
    DocumentRoot /var/www/my_app/current/web

    <Directory /var/www/my_app/current/web>
        AllowOverride All
        Require all granted
        Allow from All

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

    ErrorLog ${APACHE_LOG_DIR}/${APP_NAME}-error.log
    CustomLog ${APACHE_LOG_DIR}/${APP_NAME}-access.log combined
</VirtualHost>

UPDATE: Stage dependent configurations are shown here in details. http://www.inanzzz.com/index.php/post/0ew3/deploying-a-symfony-applications-to-staging-and-production-servers-with-capistrano