Turn Off WordPress Homepage URL Redirection

If you are integrating WordPress into a preexisting site that already has its own homepage, or if you are developing a new WordPress website that is hidden behind a Coming Soon page, you will run into one frustrating problem. If you try to access the WordPress installation by visiting the index.php file, you won’t be able to see it. Instead, WordPress will automatically redirect you from the index.php page to the blog address url, as defined in your WordPress site settings.

There are, of course, several ways to get around this problem. Two common ways include:

  1. developing the WordPress site in its own directory
  2. integrating the preexisting site or coming soon page within the WordPress site

Unfortunately, these methods can result in quite a bit of extra work. Fortunately, it is easy to stop WordPress’ automatic redirects. But first, it is a good idea to know why WordPress employs these redirects.

Why WordPress Has Automatic URL Redirects

A page on any website, WordPress or not, can be accessed by multiple urls. For example, you can typically visit the home page of a WordPress web site by all of the following urls:

  • http://example.com/
  • http://www.example.com/
  • http://example.com/index.php
  • http://www.example.com/index.php

The problem with allowing all of these ways to access a single page is that it can potentially hurt your website’s overall search engine optimization (SEO). Having multiple urls for a page means that search engines could index duplicate copies. So WordPress fixes this problem by employing automatic redirects known as Canonical URL Redirection, which only enables one url per page.

How To Turn Off Canonical URL Redirection

To turn off Canonical URL Redirection, you can add the following code to your theme’s functions.php file.


Not comfortable altering your theme files? WP developer Mark Jaquith has placed this code in his Disable Canonical URL Redirection plugin.


To learn more about the introduction of Canonical URLs, see Migrating Plugins and Themes to 2.3 in the WordPress Codex.

Tags: , , ,

25 Responses to “Turn Off WordPress Homepage URL Redirection”

  • stratosg May 4, 2009 at 8:10 am

    I hadn’t looked into it but i was wondering if this can be done at all. Although you have to be very careful when doing it since duplicate content is not generally a good idea. Nice to see you back ;)

  • Harsh Agrawal May 5, 2009 at 12:33 am

    I still prefer Index.html method to be the best and handy

  • Ajith May 7, 2009 at 2:29 am

    Hey welcome back. Where have you been?

    Thanks for this little tip on WP URL redirection

  • Christian August 5, 2009 at 5:19 pm

    Thank you… Didn’t even know there was a plugin yet… Love the idea of not needing to alter existing php

  • Steve @ Find Retro Shower Curtain October 16, 2009 at 3:45 am

    I agree, I don’t like altering .php files. I have done it but I’m never quite sure I’m not screwing something up in the process. Come to think of it, it caused me to delete and reload themes a few times. Thanks for the tip on the plugin. It will come in handy.

  • laura November 3, 2009 at 9:27 pm

    hi frien. how do you think about the pretty link. Its a redirection used to create redirection. are you think it will droped our web from search engine?

  • Ryan February 5, 2010 at 10:25 am

    Thank you for this. One Google search and I got my answer!

  • Bnpositive February 5, 2010 at 3:09 pm

    You can also use the All-In-One SEO plug-in which turns this function without editing the PHP yourself. I’m a big supporter, fan and friend of Mark Jaquith’s work, but this plug-in provides a lot more features as well if you’re going to install a plug-in.

  • Brian D. Hawkins February 28, 2010 at 9:17 am

    I guess I prefer the ‘extra work’ method. I use a sub-domain and match the headers to function site wide. Turning off the canonical URL redirection seems dangerous but I can see why some would go that route.

  • em May 27, 2010 at 12:38 pm

    I know I sound like a numpty but were do I put the plugin file?! I’ve downloaded ‘disable-canonical-redirects.php’ but don’t know were to upload it now?

  • Webvet August 6, 2010 at 11:43 am

    One main reason to turn this off in WP is for a very simple fact… and it relates to SEO; and take it from me, I have a been a full-time web developer for 12 years. The way WP wrote the redirect is bad. If you submit your site to Google, or it just finds it as www.yourdomain.com, and the WP redirect is set to yourdomain.com – Google will see a 301 message for www, but instead of following it, the bot will stop dead. So the bot never actually indexes any of your content! Yahoo.com bot does the same. So, you can either worry about the negligible issue of having duplicate content indexed, or settle with no content index at all… I choose multiple content.

    • Harry Rate February 16, 2011 at 10:52 am

      Sure it may be simpler to have multiple content, but it really does hurt your SEO.

      I wasn’t aware of the 301 problem, so should investigate. But could this be sorted out by setting the preferred domain in webmaster tools?

  • Career Outlook August 14, 2010 at 5:48 pm

    Very useful tutorial and I didn’t know that wordpress has a automatic redirection system. It could also cause the duplicate content issue within a site.

  • Ajay October 6, 2010 at 10:54 pm

    Just found out that if you are using redirect plugin you need to go to redirection > groups > and remove the latest redirection as automatically setup.
    Wordpress 3.0 seems to stuff this up with the redirection plugin.

  • pageblip December 24, 2010 at 11:45 pm

    is it possible to rename index.php?
    i face this problem for some time. but still can’t get any answer on the internet. :(

  • Abonk January 28, 2011 at 11:33 pm

    I have problem with cononical url, i was disabled the canonical url, and setting my .htaccess to redirect my blog from without www to using www, after that i can’t login to my admin page, my password was wrong..
    if i using without www i can login. any solution ?


  • Renee January 29, 2011 at 6:43 pm

    I tried the solutions mentioned here on my WP 3.0.4 install. They did not help. What did was temporarily commenting out this line on \wp-includes\canonical.php –
    add_action(‘template_redirect’, ‘redirect_canonical’);

    I will comment it back in when the site is ready to go.

  • Sebastian @ Dinosaur Games February 5, 2011 at 12:49 pm

    Finding this article two months back would have saved me loads of time…
    I installed a new wordpress site and had big problems because I had put in a single HTML site for the first time in conjunction with the wordpress installation. It always redirected from sites to other sites with no apparant reason and I had no idea how to fix it x_x

    Now I’ll know where to look at if I should run into that again. Thanks.

  • jodi February 12, 2011 at 7:12 pm

    i tried what renee did and it works fine for the index.php page, however, when i click on the dummy ‘about’ page in the default template, it jumps back to the live index.html page – am i missing something obvious? thanks

  • jodi February 13, 2011 at 3:43 pm

    hi again

    fixed!!! mayur told me to change the permalink setting to month/date and it’s working now :)

  • Goran March 23, 2011 at 4:53 am

    After 3 hours of work and searching for a solution that would solve my redirect problem, I have finally fount this website and I would like to thank tha author thousend times for this post.

  • dub2dub September 14, 2011 at 10:58 am

    I set up a new installation of WordPress in my addon domain’s root directory. I’ve created the webiste and everything. When I type in the url of my website, for example: http://example.com the site goes to a “Not Found” page, but my site is showing and if I click the “home” tab on the site, it shows my homepage correctly. Why isn’t my correct homepage showing when I type in my URL? Can someone please help me.

  • MJG August 17, 2012 at 1:09 pm

    Wow, this worked great. This is the perfect answer to a particular need that I had run into.

    The only problem is if the site is using one or more WordPress menus, it will force the url defined in the General tab rather than giving you the relative link that you want/need to support multiple domains on the site.

    Any thoughts or ideas on how to disable this behavior in the menus?

  • Justin December 11, 2012 at 12:02 pm

    Thank you! Just what I was looking for and that simple line of code worked perfectly.


Wanna run a Wordpress Network on multiple ports? | WebXL Consulting LLC

Trackback URL:

Leave a Reply

Want us to work on your project?

Contact us today for a quote. Click here to submit details regarding your project.

If you are making a general inquiry, send an email to info@velvetblues.com

Go Daddy Deal of the Week: Cheap .COM Domains! Offer expires soon!