I am attempting to convert rewrite rules to Nginx, and since due to the mass amount of rewrites we must convert, I've been trying to write a script to help me on a specific part, easily.
So far I have this:
rewrite ^action/static/([^\/]+)/$ staticPage.php?pg=$1&%$query_string;
What I want done is if 2nd column matches the regex that it doesn't have a "/" on it, to replace it, so the above it will convert it to:
rewrite ^/action/static/([^\/]+)/$ /staticPage.php?pg=$1&%$query_string;
If I can figure out how to change a specific column if it matches a specific regexp expression, I can do the same for the 3rd column.
So far I tried:
awk '/\^[a-f]/{gsub(/^/, "^/",2)};{print}'
Maybe I am doing this all wrong? I never fooled around with regexp, specific columns, and substituting them.
I have a very special cookie if I can figure out a solution to this