Redirecting HTTP requests

4

I have the following problem: I want to redirect (through .htaccess) the urls below with temporary redirect ( HTTP/1.1 302 Moved Temporarily )

Examples:

  • http://www.site.com.br/artigo/0/ to http://www.site.com.br/artigo/1/
  • http://www.site.com.br/artigo/2/ to http://www.site.com.br/artigo/1/
  • http://www.site.com.br/artigo/3/ to http://www.site.com.br/artigo/1/
  • etc.

Pe

    
asked by anonymous 18.02.2014 / 16:02

2 answers

1

Add to your .htaccess:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^/?artigo/[023]$ /artigo/1 [R=302,L,QSA]
</IfModule>
    
19.02.2014 / 03:21
0

You can use this rule:

<IfModule mod_rewrite.c>
RewriteEngine On
#regra de redirecionamento de urls antigas
redirectMatch 302 ^(.*)$ http://www.site.com.br/artigo/1/
</IfModule>

You will redirect all pages to the same place.

Credits for Segio Ronei at 301 and 302 Redirect

V2: For only articles you can change the Regular Expression to ^ (article \ / *) $

<IfModule mod_rewrite.c>
RewriteEngine On
#regra de redirecionamento de urls antigas
redirectMatch 302 ^(artigo\/*)$ http://www.site.com.br/artigo/1/
</IfModule>

so all URLs that contain link will be redirected.

    
18.02.2014 / 16:57