leslieg Posted February 25, 2015 Share Posted February 25, 2015 Hi, I really have no idea what I am doing when it comes to php, any help is very gratefully accepted. I am trying to set an out put of noindex, follow on pages when the URL contains /10-pages/ I have tried the following, but doesn't work and also the one below. I am using Joomla, but I don't know if that matters. <?php if (preg_match(‘\pages\‘, $_SERVER[php_SELF])) { echo <META NAME="ROBOTS" CONTENT="NOINDEX, FOLLOW"> } ?> <? if (preg_match(‘/page-10/‘, $_SERVER[‘REQUEST_URI’])) { ?>put your meta no index here<? } ?> Any ideas? Quote Link to comment Share on other sites More sharing options...
tryingtolearn Posted February 25, 2015 Share Posted February 25, 2015 One way could be to parse the url using the PHP_URL_PATH component to extract the /10-pages/ part Then find out if the component contains what you are looking for if it does, add your meta tag. <?php $url = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); $pos = strripos($url, "/10-pages/"); if ($pos !== false) { echo '<META NAME="ROBOTS" CONTENT="NOINDEX, FOLLOW">'; } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.