Forums

[resolved] How can I turn off Wordpress' index.php redirect to domain root? (13 posts)

  1. grumpster
    Member
    Posted 10 months ago #

    Wordpress Version: 2.7
    OS: Linux

    Situation: I have just installed Wordpress in the background of an existing website that uses index.shtml as its index page.

    Wordpress is installed and working fine, but I cannot view the Wordpress site unless I use an htaccess file to force the DirectoryIndex to be index.php.

    When I do that, of course, the whole world sees my incomplete Wordpress site. It's akin to walking in on your date when she's half dressed. Not cool (in her opinion).

    Question: How can I turn off Wordpress' apparent default tendency to redirect the index.php page to the http://www.domain.tld/ root?

    Side Note: I tried setting the "WordPress address (URL)" field in the General Settings to http://www.domain.tld/index.php and completely borked the site. I couldn't even log into the admin dashboard after that. I eventually had to edit the URL field value by going into the options table in the database itself. Sheesh!

  2. design_dolphin
    Member
    Posted 10 months ago #

    Do a net search on:

    ".htaccess redirect maintenance"

  3. KeyTechJosh
    Member
    Posted 10 months ago #

    grumpster,

    Can you explain how you reset the database? I'm having the same issue, the redirects got screwed up and now I can't get back to the wp-admin page!

    -Josh

  4. grumpster
    Member
    Posted 10 months ago #

    design_dolphin,

    Thanks for the suggestion, but that's not what I'm trying to achieve. What your link suggests merely provides a redirect page that says "We're Upgrading. Come back soon!"

    Let me try to be more clear about my needs:

    The site in question is rather large. It will take me several days to move all the content in the existing static .shtml pages into the new Wordpress site. During that time, I want the existing static HTML site to remain online and available to visitors.

    In the past, when I have upgraded static HTML websites to any of a number of different PHP-based CMS, I can install the CMS in the root directory of the existing static site, and so long as I provide a DirectoryIndex index.htm line in the htaccess file, visitors to the site will continue to see the old site.

    While those visitors are happily viewing the old site, I can type in the direct URL to the new CMS in development http://www.domain.tld/index.php and that will give me the homepage of the as-yet unfinished PHP-based CMS site because those CMS don't strip the /index.php off the URL.

    But, Wordpress seems to want to strip the /index.php off of the URL and send me automatically to the domain.tld/. It is probably doing that for SEO reasons (I'm guessing they want to prevent search engines from seeing duplicate content for domain.tld/ and domain.tld/index.[htm|php|shtml|etc.] Unfortunately, as long as there is an index.htm file, the server is going to serve that index.htm page first, unless, as I said above, I force it to serve the index.php using the htaccess file ... but that leads back to my original problem again: visitors seeing a partially finished Wordpress site.

    So, I know my way around a .htaccess file, but I can't get around Wordpress' desire to strip the /index.php off the URL without so much as a "by your leave".

    I've searched the various core files for this URL truncating behavior, but I can't seem to find the line. I thought maybe it was the ABSPATH setting on line 20 of the wp-load.php file ...

    /** Define ABSPATH as this files directory */
    define( 'ABSPATH', dirname(__FILE__) . '/' );

    I changed it to ...

    /** Define ABSPATH as this files directory */
    define( 'ABSPATH', dirname(__FILE__) . '/index.php' );

    ... but that made no difference.

    So, now, for the time being, I'm stumped.

    I do know this ... I seem to be the only person having this problem ... and that usually means I'm missing something very basic ... so please, keep the suggestions coming.

  5. grumpster
    Member
    Posted 10 months ago #

    Ha!

    I still can't get the domain.tld/index.php to show, but I can now see the individual posts because I changed a setting in the Permalinks section.

    Admin Dashboard > Settings > Permalinks

    I changed the URL formatting of the permalinks from Default to Numeric.

    With the new setting, instead of the default URL which was http://domain.tld/?p=8, I now get http://domain.tld/archives/8, which gets around that whole home directory baloney.

    Moving on ...

    But I'd still like to know if it's possible to make WP stop taking that index.php off of the URL.

  6. grumpster
    Member
    Posted 10 months ago #

    KeyTechJosh,

    Sorry, I just saw your post now.

    If you borked your site by changing the WordPress address (URL) value, you can change it back by editing the value directly in the database.

    In my case, I used PHPMyAdmin to make the edit.

    In PHPMyAdmin, find the table named wp-options in the left-hand column that lists all the table names.

    Once you've clicked on wp-options, click the Browse tab at the top of the main PHPMyAdmin info area to the right of the table name listing column.

    This will bring up a list of fields in the wp-options table. The first row has an option_name of siteurl. Click the pencil icon on the left of that row.

    You can now edit the WordPress address (URL) value directly. When you are done editing, click "Go" at the bottom of the editing area and your site will, we hope, come back online and you can log into the admin area.

  7. design_dolphin
    Member
    Posted 10 months ago #

    o.k. I see what you mean, and thanks for clearing that up.

    I think somebody with more WordPress experience will have to help you with that, because I wouldn't know how to do it that way.

    One caveat I see with your theory is: how many files depend on the removal of the index.php from the url? You might get an instable system if you do remove it, and maybe not right away, but somewhere down the line. So you would have to be absolutely sure you got everything, and nothing else, such as plugins, depending on it.

    Have you considered installing WordPress into a subdirectory, and doing it that way? Might be the best way to go in this case.

  8. mrmist
    Member
    Posted 10 months ago #

    To address the original question, you can turn off canonical redirection by putting this into your plugins directory -

    <?php
    /*
    Plugin Name: Disable Canonical URL Redirection
    Description: Disables the "Canonical URL Redirect" features of WordPress 2.3 and above.
    Version: 1.0
    Author: Mark Jaquith
    Author URI: http://markjaquith.com/
    */ 
    
    remove_filter('template_redirect', 'redirect_canonical'); 
    
    ?>

    From http://txfx.net/files/wordpress/disable-canonical-redirects.phps.

    This should turn off that feature. Whether or not your setup will work as you need is another thing.

  9. grumpster
    Member
    Posted 10 months ago #

    mrmist,

    Dude, you rock. That plugin script works like a charm.

    Thank you for showing me that, and my thanks to Mark Jaquith for writing it.

    :)

  10. anthonyb
    Member
    Posted 8 months ago #

    Thanks for this, worked for me too.

  11. Will Brownsberger
    Member
    Posted 7 months ago #

    Big thanks!!!!!!!! Works for me too!

    Notes for the next person: Was running in the xo environment. xo installs at a lower version and I upgraded directly to 2.7.1. My installation was in the directory web/wordpress and I was bouncing out to web/index.html

  12. mayurj
    Member
    Posted 4 months ago #

    FINALLY!!! After searching and searching, the canonical redirect plugin works great!

    YOUR SCENARIO: You want to run your wordpress installation at yourdomain.com/index.php but also want to use yourdomain.com/index.html. Both of these URLs should work at the same time and there should be no redirect from index.php to index.html.

    Here are the steps for newbies:

    1. Open your site with an FTP program
    2. navigate to /wp-content/plugins/
    3. create a new folder of any name
    4. create an index.php and put the PHP code from mrmist's comments above (use everything in the code box above) and copy to your new folder
    5. visit your wordpress backend and activate this new plugin

    I have this working at www.countercast.com/index.html and www.countercast.com/index.php. If you still need help, visit my site at www.fullmotiongroup.com for my contact info.

    Thanks Mr Mist!!!

  13. WindOnTheRunway
    Member
    Posted 3 months ago #

    mrmist: worked like a charm. Thanks!

Reply

You must log in to post.

About this Topic