Confidence
Confidence

Reputation: 2303

converting rewrite rules apache to nginx

I have a php symfony project, where I am removing apache as a server, and using nginx for performance reasons. No in my virtualhost.conf i have the following settings

<Directory "/usr/share/myvirtualhost/web">
    Require all granted
    Options -Indexes +FollowSymLinks
    AllowOverride None
    Allow from All
    <IfModule mod_rewrite.c>
        RewriteEngine On

        RewriteCond %{HTTP:X-DEVELOP-DOC-TEST} ^running$
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^(.*)$ app_doctest.php [QSA,L]

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

Now I have no idea how to convert this to proper nginx rewrite rules, especially the part with

RewriteCond %{HTTP:X-DEVELOP-DOC-TEST} ^running$

where I am checking if a header is being set, to forward the request to app_doctest.php

How can I get further from here?

Upvotes: 0

Views: 130

Answers (1)

regilero
regilero

Reputation: 30496

So here are some links to search in the right directions.

Start with that : a full doc on how to convert things from apache in the right way.

And that mean, for example, that you will not use rewrites but try_files instead.

Then for specific headers tests you can use the http_ form, your X-DEVELOP-DOC-TEST header should be in the http_x_develop_doc_test variable. Avoid if structures and prefer map or such.

Upvotes: 1

Related Questions