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

1个回答

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

dongza3124
dongza3124 尝试了不同的变化,没有任何作用..任何帮助将不胜感激
接近 3 年之前 回复
dtqu3278
dtqu3278 更多信息可在此处和此处找到我在顶部发布的链接
接近 3 年之前 回复
dqe55175
dqe55175 来自phpinfo(): - System Linux uvn-243-1.tll07.zonevs.eu 4.4.0-042stab123.9#1 SMP Thu Jun 29 13:01:59 MSK 2017 x86_64 - Server API Apache 2.0 Handler - Apache Version Apache /2.4.18(Ubuntu)
接近 3 年之前 回复
doufeng3602
doufeng3602 检查了自从我使用PHP 7以来你建议的库的版本7 - 我发现:libapache2-mod-php7.0已经是最新版本(7.0.18-0ubuntu0.16.04.1)
接近 3 年之前 回复
duanjiao6730
duanjiao6730 你的操作系统是什么? 例如 Ubuntu xxx?
接近 3 年之前 回复
dongyan7950
dongyan7950 是的我已经启用了模块重写,当我运行libapache2-mod-php5的安装它返回包'libapache2-mod-php5'没有安装候选
接近 3 年之前 回复
dsf22567
dsf22567 还有这个sudo apt-get install -y libapache2-mod-php5之前?
接近 3 年之前 回复
dongyong6045
dongyong6045 你运行a2enmod重写并重新启动apache吗?
接近 3 年之前 回复
doujiao3072
doujiao3072 谢谢你的答案,不幸的是它没有用。 请告诉我您可能需要哪些信息,以便帮助我找到此问题的根本原因
接近 3 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问