我有一个要在 Nginx 中设置的 301 重写列表。我想精确指定 uri,而不是使用正则表达式。该怎么做?
我认为应该这样做:
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;
这是最好的做法吗?
谢谢。
答案1
我会使用 map 来做到这一点。
也可能将映射放入不同的文件并包含它。
它确实实现了相同的效果,但在我看来,它更容易阅读。
看:http://wiki.nginx.org/HttpMapModule
第二个例子几乎就是您想要做的。