Answer the question
In order to leave comments, you need to log in
How to make dynamic meta tags?
There is a site in the site.ru format, there is an alias for the krd.site.ru domain. The
PHP formula sets the dynamic change of local content (city, phone numbers, maps)
How can I also make description, keywords and title dynamic meta tags?
Also, to change the city in them.
Dynamic content is implemented by PHP code, I attach.
<?php if (strpos( $_SERVER['HTTP_HOST'], 'krd.site.ru') !== false){ echo "Краснодаре"; } else { echo "Санкт-Петербурге";}
?>
Answer the question
In order to leave comments, you need to log in
if (strpos( $_SERVER['HTTP_HOST'], 'krd.site.ru') !== false)
echo "<meta name='title' content='Краснодар'>";
else
echo "<meta name='title' content='Петербург'>";
$host = $_SERVER[ 'HTTP_HOST' ];
$city = array(
"krd.site.ru" => "Краснодара",
"spb.site.ru" => "Санкт-Петербурга",
"msk.site.ru" => "Москвы",
"urp.site.ru" => "Урюпинска",
);
echo "
<header>
<meta name='title' content='Лучшие индивидуалки из'".$city[ $host ].">
</header>";
I would do it differently.
An option that would not bother much, as they say "on the knee."
I would make several files with the desired content. That is, for different cities there will be a file. And I already check the domain address condition and pull up the file I need.
The option, of course, is not ideal, but more than enough for such a simple task.
And if you want to be completely smart, then I would work through the database. Everything is the same, only it will be taken from the database.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question