How to convert apache to nginx rewrite?

Its rewrite for phpBB mod - przemo.org.

[code]RewriteEngine on

#RewriteBase /forum

RewriteRule ^cat([0-9]*).htm$ ./index.php?c=$1 [L,QSA]

RewriteRule ^(forum|.-vf)([0-9]+)-([0-9]+),([0-9]+).htm$
./viewforum.php?f=$2&topicdays=$3&start=$4 [L,QSA]
RewriteRule ^(forum|.
-vf)([0-9]+),([0-9]+).htm$
./viewforum.php?f=$2&start=$3 [L,QSA]
RewriteRule ^(forum|.*-vf)([0-9]+).htm$ ./viewforum.php?f=$2 [L,QSA]

RewriteRule ^prev_topic/([0-9]+).htm$
./viewtopic.php?t=$1&view=previous [L,QSA]
RewriteRule ^next_topic/([0-9]+).htm$ ./viewtopic.php?t=$1&view=next
[L,QSA]

RewriteRule
^(topics[0-9]/)?(.-vt)?([0-9]+)-([0-9]+)-([a-zA-Z]+),([0-9]+).htm$
./viewtopic.php?t=$3&postdays=$4&postorder=$5&start=$6 [L,QSA]
RewriteRule
^(topics[0-9]/)?(.-vt)?([0-9]+)-([0-9]+)-([a-zA-Z]+)-([a-zA-Z0-9]+),([0-9]+).htm$
./viewtopic.php?t=$3&start=$7&postdays=$4&postorder=$5&highlight=$6
[L,QSA]

RewriteRule ^(topics[0-9]/)?(.-vt)?([0-9]+),([0-9]+).htm$
./viewtopic.php?t=$3&start=$4 [L,QSA]
RewriteRule ^(topics[0-9]/)?(.-vt)?([0-9]+).htm$ ./viewtopic.php?t=$3
[L,QSA]
RewriteRule ^postlink/([0-9]+).htm$ ./viewtopic.php?p=$1 [L,QSA]

RewriteRule ^search.htm/authors/(.+),([0-9]+)$
./search.php?search_author=$1&start=$2 [L,QSA]

RewriteRule ^search.htm/([0-9a-z]+),([0-9]+)$
./search.php?search_id=$1&start=$2 [L,QSA]
RewriteRule ^search.htm/([0-9a-z]+)$ ./search.php?search_id=$1 [L,QSA]

RewriteRule ^members/([a-z]+)_([a-z]*)-([A-Za-z]+),([0-9]+).htm$
./memberlist.php?letter=$2&mode=$1&order=$3&start=$4 [L,QSA]
RewriteRule ^members(.htm|/?)$ ./memberlist.php [L,QSA]

RewriteRule ^profiles/([0-9]+).htm$ ./profile.php?mode=viewprofile&u=$1
[L,QSA]

RewriteRule ^groups/?([0-9]*)(.htm)?$ ./groupcp.php?g=$1 [L,QSA]
RewriteRule ^groups/?$ ./groupcp.php [L,QSA]

RewriteRule ^sitemap,([0-9]+).htm$ ./sitemap.php?offset=$1 [L,QSA]

RewriteRule ^topics([0-9]+)/?$ ./viewforum.php?f=$1.htm [L,QSA]
RewriteRule ^(topics|postlink|prev_topic|next_topic)/?$ ./index.php
[L,QSA]
RewriteRule ^profiles/?$ ./memberlist.php [L,QSA]

#htm to php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} (.).htm
RewriteRule ^(.+).htm(?.
)? $1.php$2 [E=WasHTML:yes]
RewriteCond %{ENV:WasHTML} ^yes$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+).php(?.*)? $1.htm$2
[/code]

Can anybody help me to translate this to nginx rewrite?

Posted at Nginx Forum:

Its easy e.g the first one is
rewrite ^cat([0-9]*).htm$ index.php?c=$1;

I think something using try_files but I dont really understand the
rewritecond

Okay…

rewrite ^/cat([0-9]*)\.htm$ index.php?c=$1; rewrite ^/(forum|.*-vf)([0-9]+)-([0-9]+),([0-9]+)\.htm$ viewforum.php?f=$2&topicdays=$3&start=$4; rewrite ^/(forum|.*-vf)([0-9]+),([0-9]+)\.htm$ viewforum.php?f=$2&start=$3; rewrite ^/(forum|.*-vf)([0-9]+)\.htm$ viewforum.php?f=$2; rewrite ^/prev_topic/([0-9]+)\.htm$ viewtopic.php?t=$1&view=previous; rewrite ^/next_topic/([0-9]+)\.htm$ viewtopic.php?t=$1&view=next; rewrite ^/(topics[0-9]*/)?(.*-vt)?([0-9]+)-([0-9]+)-([a-zA-Z]+),([0-9]+)\.htm$ viewtopic.php?t=$3&postdays=$4&postorder=$5&start=$6; rewrite ^/(topics[0-9]*/)?(.*-vt)?([0-9]+)-([0-9]+)-([a-zA-Z]+)-([a-zA-Z0-9]+),([0-9]+)\.htm$ viewtopic.php?t=$3&start=$7&postdays=$4&postorder=$5&highlight=$6; rewrite ^/(topics[0-9]*/)?(.*-vt)?([0-9]+),([0-9]+)\.htm$ viewtopic.php?t=$3&start=$4; rewrite ^/(topics[0-9]*/)?(.*-vt)?([0-9]+)\.htm$ viewtopic.php?t=$3; rewrite ^/postlink/([0-9]+)\.htm$ viewtopic.php?p=$1; rewrite ^/search\.htm/authors/(.+),([0-9]+)$ search.php?search_author=$1&start=$2; rewrite ^/search\.htm/([0-9a-z]+),([0-9]+)$ search.php?search_id=$1&start=$2; rewrite ^/search\.htm/([0-9a-z]+)$ search.php?search_id=$1; rewrite ^/members/([a-z]+)_([a-z]*)-([A-Za-z]+),([0-9]+)\.htm$ memberlist.php?letter=$2&mode=$1&order=$3&start=$4; rewrite ^/members(\.htm|/?)$ memberlist.php; rewrite ^/profiles/([0-9]+)\.htm$ profile.php?mode=viewprofile&u=$1; rewrite ^/groups/?([0-9]*)(\.htm)?$ groupcp.php?g=$1; rewrite ^/groups/?$ groupcp.php; rewrite ^/sitemap,([0-9]+)\.htm$ sitemap.php?offset=$1; rewrite ^/topics([0-9]+)/?$ viewforum.php?f=$1.htm; rewrite ^/(topics|postlink|prev_topic|next_topic)/?$ index.php; rewrite ^/profiles/?$ memberlist.php; rewrite ^/(.+)\.htm(\?.*)? /$1.php$2; rewrite ^/(.+)\.php(\?.*)? /$1.htm$2;

But I dont know how translate RewriteCond?

And this rewrite dont working in 100%.
http://www.landwirtschafts.net/cat4.htm - working
http://www.landwirtschafts.net/portal.htm - dont working
http://www.landwirtschafts.net/index.htm - dont working
http://www.landwirtschafts.net/members.htm - dont working

How to fix it?

Posted at Nginx Forum:

Anybody help?

Posted at Nginx Forum:

Anybody can help? Please…

Posted at Nginx Forum:

On Mon, Nov 1, 2010 at 6:44 PM, dong [email protected] wrote:

Anybody can help? Please…

maybe you can try helping yourself by reading these…

http://wiki.nginx.org/HttpCoreModule

http://wiki.nginx.org/HttpRewriteModule

as your particular problem is not too interesting and requires
extensive testing from your web application itself.


O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

I think,
apache rewrite module is used heavily in many php based websites,
so,
nginx developers should make it easy to convert apache rewrite rules
so that people can swtich to nginx more easily.

I agree. Listening in on this mailing list, I constantly hear of
requests to
convert an apache setup to nginx.

Having a tool to capture 80% of the easy Apache configs might be really
helpful for folks. I realize this is a hard problem, so this is not said
lightly.

Perhaps a future Google Summer of Code project?

-peter

On 11/1/10 11:27 AM, Peter Portante wrote:

I agree. Listening in on this mailing list, I constantly hear of requests to
convert an apache setup to nginx.

Having a tool to capture 80% of the easy Apache configs might be really
helpful for folks. I realize this is a hard problem, so this is not said
lightly.

Perhaps a future Google Summer of Code project?

-peter

95% or more are so simple that it would be a waste of time and effort.

Top posting because that’s where the insertion point is, is like
shitting in your pants because that’s where your asshole is.

On 11/1/10 10:48 AM, "bvidinli"[email protected] wrote:

I think,
apache rewrite module is used heavily in many php based websites,
so,
nginx developers should make it easy to convert apache rewrite rules
so that people can swtich to nginx more easily.

It is easy most of the time. Igor writes nginx for his employer and it
is released to the public through their kindness. He and Maxim and the
other more expert users and those knowledgeable with the code post to
this list in their free time and provide that support for free.
Generally if one asks a reasonable question and shows that they have
made efforts at searching for a solution, someone will be more than
happy to help. Being lazy and posting a list of 50-100 rewrites, most of
which are straightforward, is likely to be ignored.

Why?
Because it breaks the logical flow of conversation, plus makes
messages unreadable.

Top-Posting is evil.



nginx mailing list
[email protected]
nginx Info Page


Jim O.

Having a tool to capture 80% of the easy Apache configs might be
really helpful for folks.
http://www.anilcetin.com/convert-apache-htaccess-to-nginx/

Agree,

laziness, we are lazy, most of computer users/programmers lazy… :slight_smile:
lazy, stupid, asshole, whatever you call it, thats it…
what they say: “KISS, keep it simple stupid”, but I say also “KISC:
keep it simple clever.”

anyway,
an “automatic translater, as a program, or web service, or optionally,
same rewrite works on nginx” is mostly preferable…

wauww… thanks.
teşekkürler dostum…

You heavily need to re-arrange rewrites.

mow its not working on my rules. this script only change RewriteRule to
rewrite. nothing else.

Posted at Nginx Forum:

But I dont know how…

Posted at Nginx Forum: