V
V
Vladimir Novitsky2015-02-05 09:39:38
PHP
Vladimir Novitsky, 2015-02-05 09:39:38

What is the best redirect method to use?

Hello.
I know the following redirect methods: html, js, php, htaccess.
Which way is better (more correct, more reliable, more efficient, etc.) to use?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
D
Dmitry Entelis, 2015-02-05
@Novitsky

Redirecting via html is imho evil from ancient times when js was rare and little used.
Through js - ok, but search engines (except google and how lucky) will not understand + it may not work in some kind of opera mini for example.
php - ok, you can set up some kind of complex logic, take data for a redirect from the database, etc. but it requires some kind of qualification + intervention in the code + extra load on the server (full-fledged launch of the script).
htaccess - ok, faster than php, but there are limitations on what can be implemented (for example, it will not work without perversions to solve the problem "there are 10,000 products using links like /good/1234, you need to redirect to /1234-kusok-derma-na-palke" .
We do general application routing through .htaccess (in fact, through nginx, but the nginx config is historically auto-assembled based on .htaccess), all sorts of seo troubles - through php

I
index0h, 2015-02-05
@index0h

Depends on TK.
If you need to process the request on the server and the redirect is dynamic - php.
If you need a permanent, but cheaper and static redirect - htaccess.
If you need a dynamic redirect, but without unnecessary requests to the server - js.
html redirect, well, I don't even know, it's probably for clients without full http support and without js.

K
KorsaR-ZN, 2015-02-05
@KorsaR-ZN

All methods are acceptable, and quite reliable (JS may not work if it is disabled in the browser).
It all depends on the specific task.
It is stupid to do a redirect in connection with some logic in PHP in the front, and it is also not reasonable to do a redirect in connection with the logic of the web server in the backend or front. So, it depends on the explicit task that should provoke a redirect.

F
FanatPHP, 2015-02-05
@FanatPHP

There is a spoon, fork, knife and can opener.
WHAT IS BETTER TO USE FOR FOOD?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question