I am looking for best method without any plugin that will redirect my homepage to category url. e.g

Main page: https://uk49sresult.co.uk/

Direct redirect to this one.

Category URL: https://uk49sresult.co.uk/lunchtime-results/

It helps me to reduce the servers response time.

I have readed many answers but not provided full guideline. Please briefly explain me which code will paste to which file. I have no experience of programming but work a little bit.


You can use the following code:

add_action( 'request', function( $request ){
    if( empty( $request ) ){
        wp_safe_redirect( get_home_url() . '/lunchtime-results/' );
    return $request;

This can be added to your theme's functions.php file.

The code checks the current request arguments. When visiting the home page the request is empty; in all other cases it would include some arguments.

So if the request is empty (is home page) it redirects to a new URL setting the HTTP status to 302(Found).

  • Thanks a lot. I am also using the "HTTPS" will this code also work for the HTTPS like same in the questions?
    – 49 ideas
    Dec 12 '20 at 9:35
  • Yes the hook would work the same for HTTP and HTTPS
    – freejack
    Dec 13 '20 at 17:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.