0

I tried this Nginx rule based on this answer Nginx URL Rewrite with Multiple Parameters:

location /logs {
  rewrite "^/logs/([a-zA-Z]+)/([a-zA-Z]+)/([a-zA-Z]+)/([a-zA-Z]{3})$" 
          /index.php?y=$1&m=$2&d=$3&view=$4 last;
}

to make php accept parameters with slashes http://test.com/logs/index.php?y=%s&m=%s&d=%s&view=%s, like:

http://test.com/logs/2014/
http://test.com/logs/2014/9/
http://test.com/logs/2014/9/13/
http://test.com/logs/2014/9/13/error/

and I can't get it to work.

4
  • Try to add numeric part to your regexp: [a-zA-Z0-9] Commented Sep 13, 2014 at 12:56
  • @Phantom nope it doesnt work either. I've tried the simplest rule rewrite "^/logs/([a-zA-Z]+)$" /index.php?y=$1 last;. Commented Sep 13, 2014 at 13:14
  • I don't understand, do you want the logs?y=2014&m... to be converted to /logs/2014/... or the other way around? Commented Sep 13, 2014 at 14:26
  • @materik http://test.com/logs/index.php?y=%s&m=%s&d=%s&view=%s is just an example of what url will be passing to the php to avoid answer assumption Commented Sep 13, 2014 at 16:15

0

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.