Report this

What is the reason for this report?

How do I convert this .htaccess snip to Nginx?

Posted on March 28, 2022

I have this snip of .htaccess:

RewriteCond %{REQUEST_FILENAME} index\.php
RewriteCond %{QUERY_STRING} ^id=([0-9]+)$
RewriteCond %{DOCUMENT_ROOT}/u_pages/%1.php -f
RewriteRule .* u_pages/%1.php? [L]

Using an online converter I get this:

location / {
  if ($request_filename ~ index\.php){
    rewrite ^(.*)$ /u_pages/%1.php? break;
  }
}

-Doesn’t work.

What I’m trying to do:

I have a bunch of plain .php documents in /u_pages – e.g. 123.php

I need these to have URLs like this:

example.com/index.php?id=123

The document NAME corresponds with the number after id=

Any help is greatly appreciated, thank you.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.