On Fri, Apr 29, 2016 at 8:16 PM, Jennifer <jennifer@xxxxxxxxxxxxxxxxxxxx> wrote: > I'm wanting to redirect users using a PHP script. > > If I use only a .htaccess redirect, it takes approx 1 sec to go to > the new URL. However, if I redirect to the following PHP script first, it > takes approx 3 seconds to bring up the new URL. The included > page_hit_counter.php script gets called for both, so that's not the > bottleneck. > > Can someone see what the problem might be? > > Thank you, > Jenni > > > > <?php > > $qs = $_SERVER[QUERY_STRING]; > $_REQUEST['seo_redirect'] = $qs; > > include_once('page_hit_counter.php'); > > $parts = explode('/', $qs); > > $redirect_url = 'https://www.domain.com/'.$parts[1].'/product/'.$parts[2]; > > header( 'Content-type: text/html; charset=utf-8' ); > header( 'Location: '.$redirect_url ); > > flush(); > ob_flush(); > exit; > > ?> > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -The included page_hit_counter.php script gets called for both, so that's not the bottleneck. 1) That isn't the way to decide, try commenting it out and see if there is actually any difference or not, I call it process of elimination. 2) What reason do you have for using flush/ob_flush? 3) Shouldn't make a difference but you can do the same logic without extra variables like $qs. I am also wondering how you execute PHP code (counter script) with the .htaccess redirect?