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.

6
  • 1
    which software is beeing used?
    – djdomi
    Apr 5, 2022 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? Apr 6, 2022 at 9: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 6, 2022 at 17:32
  • Disregard the file extension -- might as well be .html -- still trying to rewrite the URLs on Nginx. Apr 6, 2022 at 17:39

0

You must log in to answer this question.

Browse other questions tagged .