Htaccess - redirecting the domain

Asked

Viewed 2,013 times

4

I had Ubdomain "B2b".dominio.com.br and now I switched the files to "catalogo".dominio.com.br

I want an htaccess rule

That when you enter the http://b2b.dominio.com.br/etcqlqr-coisa/qualquercoisa

No matter what level

Be redirected to http://catalogo.dominio.com.br/etcqlqr-coisa/qualquercoisa

i think if you create several htaccess rules one for each possible level of folder would solve, only I do not know the first, to multiply

http://b2b.cellsystem.com.br/18-cabling

has to go to http://catalogo.cellsystem.com.br/18-cabeamento

as well as http://b2b.cellsystem.com.br/telecomunicacao/2-connection-cable-rpm-113-612745m.html

for http://catalogo.cellsystem.com.br/telecomunicacao/2-connection-cable-rpm-113-612745m.html

here’s the rule that I think is the way

Rewriteengine on Rewritecond %{HTTP_HOST} B2b.cellsystem.com.br [NC] Rewriterule ^(.*)$ http://catalogo.cellsystem.com.br/$1 [L,R=301]

edited:

the support Locaweb gave me this http://wiki.locaweb.com.br/pt-br/Redirecionamento_301

I’ll try, but I haven’t got it yet

edited: did not give

tentei redistribuir os arquivos index.php com o codigo em pastas com o nome de cada categoria e subcategoria, nao ta funcionando pq o produto é .html no final e nao index 

<?php
$server = $_SERVER['SERVER_NAME'];
$endereco = $_SERVER ['REQUEST_URI'];
header("Location: http://catalogo.cellsystem.com.br/{$endereco}");

but if anyone knows htaccess Agradeco

I will try to create file by html file on how much this with javascript redirect

  • the closest I could find was here http://www.hostnet.com.br/wiki/index.php/Entenda_o_arquivo_.htaccess

2 answers

3


Creating a logic in the pages would not be the best practice for this case.

Use the . htaccess engine to simplify your process.

RewriteEngine On

RewriteCond %{HTTP_HOST} www.b2b.cellsystem.com.br

RewriteCond %{REQUEST_URI} !b2b/

RewriteRule ^(.*)$ http://catalogo.dominio.com.br/$1 [L]

So any access that leaves for B2b will be redirected to cataloging, without losing the parameters at any level.

PS: take care that there is no conflict between the other directives of your . htacess

1

good afternoon guys, this code worked here:

<IfModule mod_rewrite.c>
RewriteEngine On
Redirect 301 / https://www.novodominio.com/
</IfModule>

The parameters are maintained

Browser other questions tagged

You are not signed in. Login or sign up in order to post.