Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a list of 301 rewrites to set in Nginx. And I want to specify exactly the uri instead of using regex. What's the write way to do that?

This is what I think it should be done:

rewrite /o-atipico /rogerio-madureira.htm permanent;
rewrite /CHANGELOG.txt / permanent;
rewrite /MaxLucado / permanent;
rewrite /adwords / permanent;
rewrite /animals.txt / permanent;
rewrite /apresentacao / permanent;
rewrite /arquivos / permanent;
rewrite /atipico / permanent;
rewrite /atipico.com.br / permanent;
rewrite /baix / permanent;
rewrite /baixe.asp / permanent;
rewrite /blog / permanent;
rewrite /c / permanent;
rewrite /calendario.asp / permanent;
rewrite /capture.asp / permanent;
rewrite /contato / permanent;
rewrite /contato.asp / permanent;
rewrite /conteudo.asp / permanent;
rewrite /cu / permanent;
rewrite /cur / permanent;
rewrite /curs / permanent;
rewrite /curso / permanent;
rewrite /curso.asp / permanent;
rewrite /cursoempresa.asp / permanent;
rewrite /cursoindividual.asp / permanent;
rewrite /cursoonline.asp / permanent;
rewrite /cursopresencial.asp / permanent;
rewrite /empreendedor / permanent;
rewrite /empresário / permanent;
rewrite /error_log / permanent;
rewrite /exemplo-de-codifo-semantico.html / permanent;
rewrite /favicon.bmp / permanent;
rewrite /function.file-put-contents / permanent;
rewrite /function.getimagesize / permanent;
rewrite /function.include / permanent;
rewrite /galeria.html / permanent;
rewrite /google / permanent;
rewrite /home.htm / permanent;
rewrite /home.xsl / permanent;
rewrite /hospedagem-de-sites / permanent;
rewrite /i / permanent;
rewrite /ideias-em-curso.php / permanent;
rewrite /index.php5 / permanent;
rewrite /inex.htm / permanent;
rewrite /ivar.html / permanent;
rewrite /marketing.htm / permanent;
rewrite /matricula.asp / permanent;
rewrite /me / permanent;
rewrite /muieblackcat / permanent;
rewrite /natal / permanent;
rewrite /news / permanent;
rewrite /news.html / permanent;
rewrite /obrigado / permanent;
rewrite /overview.asp / permanent;
rewrite /pagina.html / permanent;
rewrite /palestra / permanent;
rewrite /participe.asp / permanent;
rewrite /performance-de-sites / permanent;
rewrite /pesquisa.htm / permanent;
rewrite /prodo / permanent;
rewrite /prodo.asp / permanent;
rewrite /promocao. / permanent;
rewrite /promocao.asp / permanent;
rewrite /promoparti.asp / permanent;
rewrite /propaganda-e-anuncios-de / permanent;
rewrite /r / permanent;
rewrite /results.aspx / permanent;
rewrite /robost.txt / permanent;
rewrite /robots.txt / permanent;
rewrite /seo / permanent;
rewrite /shorinji / permanent;
rewrite /sites / permanent;
rewrite /sualoja.asp / permanent;
rewrite /teste.htm / permanent;
rewrite /treinamento-de-marketing.htm / permanent;
rewrite /treinamento-de-seo.htm / permanent;
rewrite /treinamento-de-vendas.htm / permanent;
rewrite /treinamentos.asp / permanent;
rewrite /vcard / permanent;
rewrite /vendas / permanent;
rewrite /vendas.htm / permanent;
rewrite /vendedor / permanent;
rewrite /xml.asp / permanent;

Is it the best way to do that?

Thanks.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

I would use map to do that.
Possibly also place the mappings into a different file and include it.
It does achieve the same, but is - in my opinion - easier to read.

See: http://wiki.nginx.org/HttpMapModule
2nd example is pretty much what you want to do.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.