M
M
My joy2014-08-31 17:58:51
PHP
My joy, 2014-08-31 17:58:51

How to replace a bunch of urls with a 301 redirect?

There are urls like:

site.ru/abc/1
site.ru/abc/2
site.ru/abc/3
...

there are a lot of them
now the task is to make aliases to these urls so that
site.ru/abc/1-title-page
site.ru/abc/2-title-page
site.ru/abc/3-title-page

advise how to do this, without consequences for the search engines, so that they don’t send a slice :)
thanks

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dmitry Entelis, 2014-08-31
@t-alexashka

In php code

header("HTTP/1.1 301 Moved Permanently"); 
header("Location: http://site.ru/abc/1-title-page"); 
die();

Below @Scorpi and @KorsaR-ZN write "make it through the web server".
Firstly, you won’t be able to make a redirect by mask, because the author needs CNC
Secondly, you can certainly make redirects by the number of pages - but this is
a) crap, because the author said that there are a lot of such pages
b) with a large number of pages it will be processed rather slowly and slow down the whole site. In php, this is 1 request to the database to get the full URL and one redirect.
That is, in fact, to show the page, it turns out +1 request to the server and +1 sql request.
I do not think that the author has a huge traffic there.

K
KorsaR-ZN, 2014-08-31
@KorsaR-ZN

If you have apache, then you need the mod_rewrite module.
and through the file (.htaccess) in the root of the site, you can make a 301 redirect by URL mask.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question