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.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hi @ ,
You can try the following redirect:
Not really sure but it should work.
Or with rewrite, the query string is automatically appended unless a ? is added: