R
R
Roman Makarov2015-12-06 08:39:39
PHP
Roman Makarov, 2015-12-06 08:39:39

How to do a redirect correctly?

The problem is that the html comes in but is not replaced. The address also remains the same. Those. instead of a full redirect, we simply initiate a request.

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) index.php?route=$1 [L,QSA]

redirect function and its call
public function redirect($url) {
        header('Location: ' . $url);
        exit;
    }
redirect('http://' . $_SERVER['HTTP_HOST'] . '/ViewCollection');

f1e1b1959d9545a597704af28086174e.png

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
DevMan, 2015-12-06
@rmakarov

At you the request hour not an ajax goes?

S
Stalker_RED, 2015-12-06
@Stalker_RED

Could you describe in more detail what exactly you want to achieve? What does it mean to "replace the old code with the new one"?

Moreover, it looks like this (request - 302 empty response - the browser executes a get request at the address specified in the redirect - it receives the html code).
It was you who described the normal operation of a 301 redirect. This is how it should work.
Maybe you wanted some other redirect ?

R
romy4, 2015-12-06
@romy4

Do you have HTTP 302 in response headers?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question