Looking for rewrite rules


#1

Hey,

i’m new to NGINX and this community so i hope this is the right place to
post my question.

I have this .htaccess which is working perfect on my apache:

Options +FollowSymlinks
RewriteEngine On
RewriteRule ^(+)/robots.txt$ robots.txt
RewriteRule ^members/page([0-9]+).html$ index.php?page=$1
RewriteRule ^whatsnew/entries/([0-9]+)/page([0-9]+).html$
browsecategory.php?do=newentries&cutoffdate=$1&page=$2
RewriteRule ^whatsnew/entries/(([0-9]?|-)+/?)$
browsecategory.php?do=newentries&cutoffdate=$1
RewriteRule ^whatsnew/posts/([0-9]+)/page([0-9]+).html$
browsecategory.php?do=newposts&cutoffdate=$1&page=$2
RewriteRule ^whatsnew/posts/(([0-9]?|-)+/?)$
browsecategory.php?do=newposts&cutoffdate=$1
RewriteRule ^whatspopular/(+)/$
browsecategory.php?do=popentries&orderby=$1
RewriteRule ^members/(+)/page([0-9]+).html$
browsecategory.php?do=member&userrewrite=$1&page=$2
RewriteRule ^members/((|-)+/?)$
browsecategory.php?do=member&userrewrite=$1
RewriteRule ^(+)/members/(+)/page([0-9]+).html$
browsecategory.php?userrewrite=$2&catrewrite=$1&page=$3
RewriteRule ^(+)/members/((|-)+/?)$
browsecategory.php?userrewrite=$2&catrewrite=$1
RewriteRule ^(+)/((|-)+)/$ showentry.php?entryrewrite=$2&catrewrite=$1
RewriteRule ^(+)/(+)/page([0-9]+).html$
showentry.php?entryrewrite=$2&catrewrite=$1&page=$3
RewriteRule ^(+)/(+)/epage([0-9]+).html$
showentry.php?entryrewrite=$2&catrewrite=$1&epage=$3
RewriteRule ^(+)/page([0-9]+).html$
browsecategory.php?catrewrite=$1&page=$2
RewriteRule ^(+)/?$ browsecategory.php?catrewrite=$1

My question is, whats the right syntax for NGINX. I was playing around a
little bit but i couldn’t get it to work.

Could you help me please?! :wink: Thanks in advance

Greetings from Germany

Florian

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,1853,1853#msg-1853


#2

Hallo,

location / {
rewrite ^(+)/robots.txt$ robots.txt last;
rewrite ^members/page([0-9]+).html$ index.php?page=$1 last;
rewrite ^whatsnew/entries/([0-9]+)/page([0-9]+).html$
browsecategory.php?do=newentries&cutoffdate=$1&page=$2 last;
rewrite ^whatsnew/entries/(([0-9]?|-)+/?)$
browsecategory.php?do=newentries&cutoffdate=$1 last;
rewrite ^whatsnew/posts/([0-9]+)/page([0-9]+).html$
browsecategory.php?do=newposts&cutoffdate=$1&page=$2 last;
rewrite ^whatsnew/posts/(([0-9]?|-)+/?)$
browsecategory.php?do=newposts&cutoffdate=$1 last;
rewrite ^whatspopular/(+)/$
browsecategory.php?do=popentries&orderby=$1 last;
rewrite ^members/(+)/page([0-9]+).html$
browsecategory.php?do=member&userrewrite=$1&page=$2 last;
rewrite ^members/((|-)+/?)$
browsecategory.php?do=member&userrewrite=$1 last;
rewrite ^(+)/members/(+)/page([0-9]+).html$
browsecategory.php?userrewrite=$2&catrewrite=$1&page=$3 last;
rewrite ^(+)/members/((|-)+/?)$
browsecategory.php?userrewrite=$2&catrewrite=$1 last;
rewrite ^(+)/((|-)+)/$ showentry.php?entryrewrite=$2&catrewrite=$1
last;
rewrite ^(+)/(+)/page([0-9]+).html$
showentry.php?entryrewrite=$2&catrewrite=$1&page=$3 last;
rewrite ^(+)/(+)/epage([0-9]+).html$
showentry.php?entryrewrite=$2&catrewrite=$1&epage=$3 last;
rewrite ^(+)/page([0-9]+).html$
browsecategory.php?catrewrite=$1&page=$2 last;
rewrite ^(+)/?$ browsecategory.php?catrewrite=$1 last;
}

Das Sollte funktionieren wenn nicht mal fehler meldung.

Kommt in die config vom nginx

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,1853,1861#msg-1861


#3

Danke für deine Hilfe! Bekomme leider immer den Fehler “No input file
specified.”

Hmmm

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,1853,1864#msg-1864


#4

Weiss nicht ob es korrekt ist, schaut aber beeindruckend. Vielleicht es
ist eine gute Idee einen automatischen Ãœbersetzer zu erstellen.


#5

You may follow
http://www.anilcetin.com/convert-apache-htaccess-to-nginx/ and give it a
try.

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,1853,1865#msg-1865


#6

Das hört sich gut an :slight_smile:

das währe praktisch.

aber wenn man einmal drin ist ist es eigentlich das gleiche wie
mod_rewrite vom apache nur am anfang anders und am ende

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,1853,1863#msg-1863