I have deployed my application to Google App Engine (PHP - Flexible Environment). After doing phpinfo(), it shows that it has Nginx Webserver by default. I am new to Nginx server. And, now I have to migrate the .htaccess URL rewrite rules in my application to the Nginx server.

Where can I create or edit Nginx URL rewrite configuration file in Google App Engine? Or can I create it in my application's root path.

Following are some .htaccess URL rewrite rules, which I have to migrate in nginx server:

Options All -Indexes

Options -Multiviews
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^channels/page/([0-9]+)/?$ channels/index.php?p=$1 [L]
RewriteRule ^channels/([_0-9a-z-]+)/?$ channels/index.php?o=$1 [L]
RewriteRule ^channels/([_0-9a-z-]+)/([0-9]+)/?$ channels/index.php?o=$1&p=$2 [L]

RewriteRule ^user/([^/]*)/$ /user/index.php?usr=$1 [L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} ^GET\ /[^?\s]+\.php
RewriteRule (.*)\.php$ /$1/ [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^(.+)/$
RewriteCond %{DOCUMENT_ROOT}%1.php -f
RewriteRule (.*)/$ $1.php [L]

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule .*[^/]$ $0/ [L,R=301]

ErrorDocument 404 /error.php

  • How about the first result when googling for "Google App Engine rewrite"? Simulate Apache mod_rewrite routing May 25, 2017 at 12:49
  • @EsaJokinen Yeah I have gone through this. But I am not able to completely migrate my url rewrite rules in this method. Can you please help me through this? May 25, 2017 at 13:02
  • Welcome to ServerFault. Unfortunately, no one can help to completely migrate the above rewrites to GAE that has its own way to implement rewrites. Someone here can help, if you tried to do something on your own and failed to achieve the desired result. So, what have you tried yourself? For example, have you tried simple redirects, such as 301, 302, etc., in GAE? May 25, 2017 at 15:20

1 Answer 1


You need to create nginx-app.conf file in your root directory, it will automatically include the rules from there during deployment

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .