• Resolved grumpster

    (@grumpster)


    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!

Viewing 15 replies - 1 through 15 (of 17 total)
  • CodePoet

    (@design_dolphin)

    Do a net search on:

    “.htaccess redirect maintenance”

    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

    Thread Starter grumpster

    (@grumpster)

    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.

    Thread Starter grumpster

    (@grumpster)

    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.

    Thread Starter grumpster

    (@grumpster)

    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.

    CodePoet

    (@design_dolphin)

    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.

    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.

    Thread Starter grumpster

    (@grumpster)

    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.

    πŸ™‚

    Thanks for this, worked for me too.

    Will Brownsberger

    (@will-brownsberger)

    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

    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 http://www.countercast.com/index.html and http://www.countercast.com/index.php. If you still need help, visit my site at http://www.fullmotiongroup.com for my contact info.

    Thanks Mr Mist!!!

    mrmist: worked like a charm. Thanks!

    Well, this wasn’t exactly my issue, but it led me to the solution, so thank you guys.

    The problem:

    Fresh install of WordPress into a subfolder, http://www.mydomain.com/blog. Setup goes fine, all seems well, until you try to go to the main page. The browser goes blank and then shows a listing of folders/files in the blog folder instead of opening index.php. Try typing in http://www.mydomain.com/blog/index.php, and you get the same result, as though you are redirected and the index.php is stripped from the URL. Oddly, typing in http://www.mydomain.com/blog/wp-admin/index.php will take you to the admin page, although, again, index.php is stripped from the URL. Incidentally, you can get to all the settings, plugins etc, but cannot view the site itself from http://www.mydomain.com/blog.

    Solution:
    Edit .htaccess and make sure index.php is included in the line for DirectoryIndex at the very top of file. In my case, it was missing, so:

    DirectoryIndex index.html

    (additional content unchanged)

    was changed to:

    DirectoryIndex index.php index.html

    (additional content unchanged)

    I HOPE this helps someone out there.

    mckenzl, What you are wanting to do is Give WordPress Its Own Directory. The explanation in the Codex here explains how to do that.

    trying to do what mayurj has done (have both html and php site live at the same time) but no luck.

    I followed exact steps and activated the “disable canonical URL redirect” plugin

    I’m on godaddy linux wordpress hosting.

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘How can I turn off WordPress’ index.php redirect to domain root?’ is closed to new replies.