What is FASTER way to redirect a particular (specific) page, a PHP or htaccess? Considering that many different pages may need such redirect on a high traffic site. e.g. what is faster:
PHP (no database queries involved, just simple plain php redirect)
header("Location: /new.php",TRUE,301);
or
htaccess
redirect 301 old.php http://site.com/new.php
Depends. In general, .htaccess will be faster because you won't have the overhead of invoking PHP. However -- if you've got 1000 redirects in a single .htaccess file at the document root level, then Apache will need to check every one of them on every page load. I.e., instead of just serving index.php, you're now going to have to do 1000 regex checks, and then serve index.php. Overall, I'd say that if you've got a lot of redirects and a lot of pages that won't be redirected, then do it in PHP. In this case, you don't pay any extra overhead for the pages that don't need to be redirected.
.htacess
are processed before php is called, so if you can create it, it will surely be faster
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With