Answer the question
In order to leave comments, you need to log in
How to specify title in htaccess for specific url?
There is an unknown CMS, which is very difficult to understand. And there is a task - to set the title I need for a specific page of the site. I read somewhere that this can be done in htaccess.
Question: how?
Answer the question
In order to leave comments, you need to log in
Create a file:
<?
$rewrite['/'] = 'Новый тайтл';
$rewrite['/about/'] = 'Новый тайтл';
ob_start("titler");
function titler($content) {
global $rewrite;
if (isset($rewrite[$_SERVER['REQUEST_URI']]))
return preg_replace("#<title>.*?</title>#",'<title>' . $rewrite[$_SERVER['REQUEST_URI']] . '</title>');
else return $content;
}
php_value auto_prepend_file "titler.php";
In the general case, this cannot be done.
If an unknown CMS displays any query parameters (the part after ?xxx) as a title, then these are its personal features (very negative).
You can specify in .htaccess if you implement it, but it will be a great crutch. Or, as an option, if the server has a filter module that will allow you to do this.
If there is a problem with the code, then you can pervert like this:
At the end of the index.php index file or whatever you have
Check $_SERVER['REQUEST_URI'] for a match with the desired url and if there is a match, output something like this
echo '' ;
The header will be replaced with javascript.
There is a module for Apache Filter where you can configure the replacement of HTML under conditions, but this is a cruel crutch. For this you have to hit on the hands.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question