简体   繁体   中英

rewrite apache to nginx

this is my first time with nginx rewrite, who can help me convert those rules to nginx sintax?

RewriteRule (economics|sport|gossip|aboutus)+$ index.php?section=$1
RewriteRule (register)+$ $1.php?%{QUERY_STRING}
RewriteCond %{QUERY_STRING} ^p
RewriteRule (economics|sport|gossip)/+$ articles.php?section=$1&%{QUERY_STRING}

thank you

rewrite (economics|sport|gossip|aboutus)$ /index.php?section=$1 last;

I'm not sure what the purpose of the + is in your original regex. Can there be more than one of the four words? Have you tried matching for just one of those words (ie is the problem the "or" part)? Why "break" instead of "last" for the rewrite directive ?

rewrite (register)+$ $1.php last;

Again, I'm not sure what you're trying to accomplish with the + in this regex. Do you mean .+ (that is, "one or more of any character")? If so, the $ is superfluous. As you've written it, it means "one or more repetitions of the string 'register' ending the request string."

The rewrite syntax in nginx is not too entirely different.

rewrite  ^/(.*)$  http://www.just1word.com/$1  permanent;

This is one taken from a config file that I have laying around. Perhaps it will point you in the right direction.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM