1

I have this snippet of .htaccess coming from Apache:

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 the Winginx online converter I get the following:

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

But that doesn't seem to do anything.

What I'm trying to achieve:

I have regular plain php-documents in the folder /u_pages/ -- e.g. 123.php, 444.php etc.

I need each of these to have URLs on the following basis:

example.com/index.php?id=123

-where the file name (123.php) corresponds with the number after id= in the URL

Hoping someone can lend a hand. Thanks very much in advance.

Trace DeCoy
  • 153
  • 2
  • 6
  • 1
    which software is beeing used? – djdomi Apr 05 '22 at 13:55
  • Thank you!! No software for these pages, they are just static pages. However, there is a Wordpress install on the domain as well, but it's not being used to display these pages. Can you help? – Trace DeCoy Apr 06 '22 at 09:28
  • a php file is not static. So what are you trying to do? It looks for me like an enduser ehich in fwct would be not on topic for serverfault.com but may be asked on superuser.com or webmasters – djdomi Apr 06 '22 at 17:32
  • Disregard the file extension -- might as well be .html -- still trying to rewrite the URLs on Nginx. – Trace DeCoy Apr 06 '22 at 17:39
  • have you seen https://stackoverflow.com/questions/5840497/convert-htaccess-to-nginx – djdomi Apr 06 '22 at 17:43
  • I've tried the online converter, if that's what you mean. Didn't work. – Trace DeCoy Apr 06 '22 at 17:59

0 Answers0