0

I am using NGINX 1.2.3 on Ubuntu 10.4 with php5-fpm.

http://example.com/step2.php?qid=RAUVGXF

I would like to rewrite /step2.php?qid=RAUVGXF as /step2/RAUVGXF

How can I do that?

Part of my NGINX config is like below:

root /var/www;

location ~ .php$ {
fastcgi_param HTTPS on;
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_pass   unix:/var/run/php5-fpm.sock;
fastcgi_param  SCRIPT_FILENAME  /var/www$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
fastcgi_index index.php;
}
1
  • To confirm, you want to browse to http://www.example.com/step2.php?qid=RAUVGXF and actually load the asset /step2/RAUVGXF correct (this is opposite of what most people try to do)? Is "RAUVGXF" a script, a static asset, or what? Do you want the URL in the browser window to change, or do you want it to remain as http://www.example.com/step2.php?qid=RAUVGXF? Commented Jul 12, 2017 at 20:09

1 Answer 1

1

Try:

rewrite ^/step2/ /step2.php?qid= last;
Sign up to request clarification or add additional context in comments.

5 Comments

Thanks tried it but still the same url(no change) after page refresh(reload)
@Ronin: You have to change your code to change the URL. The rewrite directive just makes the server understand the new URL.
As I understand /step2/<qid> must be submitted from the php code but actually step2.php?qid=<qid> executes and nginx interprets
@Ronin: And does this not do that? (It might not; I haven't actually tried it.)
need to check with developer (I am not a code person) how he does that from the php code.. basically what I wanna see URL /step2/<qid> by running /step2.php?qid=<qid> .. will update here once we try it. this seems to be the missing piece of my puzzle...Thanks for the help..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.