Answer the question
In order to leave comments, you need to log in
Apache > NGinx rules?
Hello!
Please help me translate these Apache rules into NGinx correctly:
RewriteRule (.+)/feed /$1 [R=301,L]
RewriteRule (.+)/comment-page /$1 [R=301,L]
RewriteRule (.+)/trackback /$1 [R=301,L]
RewriteRule (.+)/comments /$1 [R=301,L]
RewriteRule (.+)/attachment /$1 [R=301,L]
RewriteCond %{QUERY_STRING} ^replytocom= [NC]
RewriteRule (.*) $1? [R=301,L]
RewriteCond %{QUERY_STRING} ^attachment_id= [NC]
RewriteRule (.*) $1? [R=301,L]
RewriteCond %{REQUEST_URI} !^/page/([0-9]+)/$
RewriteRule (.*)/([0-9]+)/$ $1/ [R=301,L]
Answer the question
In order to leave comments, you need to log in
It would take a lot of "explaining" in my opinion, so read up on regular expressions in htaccess.
Try:
location ~ /page/([0-9]+)/$ {}
location / {
rewrite (.+)/feed /$1 redirect;
rewrite (.+)/comment-page /$1 redirect;
rewrite (.+)/trackback /$1 redirect;
rewrite (.+)/comments /$1 redirect;
rewrite (.+)/attachment /$1 redirect;
if ($query_string ~* "^replytocom=") {
rewrite ^(.*)$ /$1? redirect;
}
if ($query_string ~* "^attachment_id=") {
rewrite ^(.*)$ /$1? redirect;
}
rewrite (.*)/([0-9]+)/$ /$1/ redirect;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question