Hello! Another query for you please.
We have the following PHP code in our header.php which is include_once'd in all files which is working fine, except one problem.
Basically, it ensures 'www' is present on all our URL's, and if in a directory, /index.php is shown instead of just a "/". For example, if someone visited our site like http://domain.com/copyright it would be re-wrote to http://www.domain.com/copyright/index.php - this works perfectly except on one occurence...
That is if we have a script that say has /somefile.php?id=2 it re-writes it to /somefile.php?id=2index.php - how can we prevent that please?
if (strpos ($_SERVER['HTTP_HOST'], 'www.') !== 0) {
if(preg_match("/\..{3,4}$/", $_SERVER['REQUEST_URI'])) {
header ('Location: http://www.domain.com' . $_SERVER['REQUEST_URI']);
exit();
}else{
header ('Location: http://www.domain.com' . $_SERVER['REQUEST_URI'].'index.php');
exit();
};
}else{
if(!preg_match("/\..{3,4}$/", $_SERVER['REQUEST_URI'])) {
header ('Location: http://www.domain.com' . $_SERVER['REQUEST_URI'].'index.php');
exit();
};
};
Hope this was clear to understand; if not please let me know and I'll try to explain it again.
Thanks for the continued support.
Regards,