how to write rewrite rule in nginx -


suppose have url http://www.example.com/category/travel%20accessories changed http://www.example.com/category/travelaccessories (%20 removed) can 1 tell how using nginx can redirect request http://www.example.com/category/travel%20accessories http://www.example.com/category/travelaccessories . please note travel%20accessories 1 example there many other such url space(%20) removed

regards rishi

you can not remove arbitrary number of spaces. problem rewrite have specify regular expression match whole url , replacement expression whole url.

this rewrite rule should replace 1 space in url beginning /category/:

rewrite ^(/category/.*)\ (.*)$ $1$2 permanent; 

you add more spaces captured so:

rewrite ^(/category/.*)\ (.*)\ (.*)$ $1$2$3 permanent; rewrite ^(/category/.*)\ (.*)$ $1$2 permanent; 

note need have 1 rule each possible number of spaces (1 , 2 in case).


Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -