WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] HTAccess Rule problem (17 posts)

  1. stonegauge
    Member
    Posted 8 years ago #

    I installed 2.0 to a two websites that are live on the net -- http://www.zimmermann2006.com and http://www.sticksoffire.com (just for reference). I had to contact my hosting's support people because, for soem reason unknown to me, stats that are posted on my hosts server (the host is Dreamhsot BTW) weren't showing up for some reason and redirecting me to the main pages of said websites.

    Support got back to me and noted that HTAccess (default install of HTaccess at that) was posting lines that were preventing the stats link from working::

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php

    Now, seeing my HTAccess files (which I hadn't viewed until talking with support) contain not much more than this, is it going to break something if I remove these trouble lines from my HTAccess files on said sites listed above?

  2. stonegauge
    Member
    Posted 8 years ago #

    Yeah, that cauxses a problem all right -- now I can't get to any of the site pages.... blah. (this problem was fixed by just re-approving permalink structure -- butttt the domain I am trying to access for server stats becomes unavalible again)

  3. stonegauge
    Member
    Posted 8 years ago #

    This isn't resolved in Full but there was a fix presented to me by Dreamhost tech support. It can be found here:

    http://wiki.dreamhost.com/index.php/Making_stats_accessible_with_htaccess

  4. infinitewarrior
    Member
    Posted 8 years ago #

    Unfortunately, that doesn't work with 2.0. Removing that rewrite rule will actually get you to the directory. (You'll get the password prompt if it's protected.) It still doesn't show you stats, though, just a 404.

    WP doesn't appear to write anything to .htaccess anymore. So, what might have changed in 2.0 that would affect this...?

  5. infinitewarrior
    Member
    Posted 8 years ago #

    Resolved? What's the answer? :)

    Correction: Nothing seems to be *different* .htaccess-wise between 1.5 and 2.0. Just suddenly stopped working on upgrade. :\

  6. stonegauge
    Member
    Posted 8 years ago #

    It was resolved as there is a resolution presented on Dreamhost's wiki....

    Many CMS and blog tools install a .htaccess file that makes our stats unreachable, including our WordPress 2.0 one-click install. They usually look something like:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php
    </IfModule>
    # END WordPress

    To fix this you need to add the following lines to your .htaccess immediately after the the RewriteBase line

    RewriteCond %{REQUEST_URI} ^/stats/(.*)$ [OR]
    RewriteCond %{REQUEST_URI} ^/failed_auth.html$
    RewriteRule ^.*$ - [L]

    So the final .htaccess file would look like:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_URI} ^/stats/(.*)$ [OR]
    RewriteCond %{REQUEST_URI} ^/failed_auth.html$
    RewriteRule ^.*$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php
    </IfModule>
    # END WordPress

  7. stonegauge
    Member
    Posted 8 years ago #

    OK this is NOT resolved.

    For soem reason, every time I upload an edited .htaccess file, it works for a little bit and then stops working and reverts back to the original HTaccess file...

  8. snidog
    Member
    Posted 8 years ago #

    Thanks for pointing out that fix, stonegauge. It worked perfectly for me.

  9. roshangupta
    Member
    Posted 8 years ago #

    This plugin should take care of it.

    <?php
    /*
    Plugin Name: Dreamhost Stats
    Plugin URI: http://atastandstill.com
    Description: Prevents WordPress from intercepting the Dreamhost stats page by modifying the .htaccess file.
    Author: Roshan Gupta
    Version: 1.0
    Author URI: http://atastandstill.com/
    */

    function enable_dreamhost_stats($content) {
    if (strpos($content, 'RewriteBase /') !== FALSE) {
    $content = str_replace('RewriteBase /',
    'RewriteBase /' . "\n" . 'RewriteCond %{REQUEST_URI} ^/stats/(.*)$ [OR]' . "\n" .
    'RewriteCond %{REQUEST_URI} ^/failed_auth.html$' . "\n" . 'RewriteRule ^.*$ - [L]', $content);
    }
    else {
    $content = str_replace('RewriteEngine On',
    'RewriteEngine On' . "\n" . 'RewriteCond %{REQUEST_URI} ^/stats/(.*)$ [OR]' . "\n" .
    'RewriteCond %{REQUEST_URI} ^/failed_auth.html$' . "\n" . 'RewriteRule ^.*$ - [L]', $content);
    }
    return $content;
    }

    add_filter('mod_rewrite_rules', 'enable_dreamhost_stats');

    ?>

  10. stonegauge
    Member
    Posted 8 years ago #

    Rosh, where should that code be inserted?

    Thanks

  11. Chris_K
    Member
    Posted 8 years ago #

    If I were to guess, I'd put it in a new file named something like "DreamhostStats.php" and then drop it into my plugins directory to see if it flies.

  12. stonegauge
    Member
    Posted 8 years ago #

    OK, still issues with the plugin. Saved the code (as suggested above) as dreamhoststats.php and uploaded to my plugins directory.

    When I click ACTIVATE, I get this error message:

    Warning: Cannot modify header information - headers already sent by (output started at /home/.kafka/rtfldgr/boltsmag.com/wp-content/plugins/dreamhoststats.php:27) in /home/.kafka/rtfldgr/boltsmag.com/wp-admin/plugins.php on line 16

    Operations seemed normal and yes - I was able to view stats fine again but I heard from a friend who also tried this about there being other call errors appearing on the Admin control panel.

    When you deactivate the plugin, there is a call error that I believe is the same as the one i posted above but on line 22 instead of 16.

  13. stonegauge
    Member
    Posted 8 years ago #

    I'd also like to note the plugin will kill RSS feeds:

    Warning: Cannot modify header information - headers already sent by (output started at /home/.kafka/rtfldgr/boltsmag.com/wp-content/plugins/dreamhoststats.php:27) in /home/.kafka/rtfldgr/boltsmag.com/wp-rss.php on line 8

  14. stonegauge
    Member
    Posted 8 years ago #

    any updates on this plugin code?

  15. Chris_K
    Member
    Posted 8 years ago #

    See if you have an empty/blank line in the source of the plugin at either the very top or very end. If you do, remove it.

    more here

  16. stonegauge
    Member
    Posted 8 years ago #

    One single space after the closing tag. Sheesh.

    That solves the ADMIN errors. Unfortunately after the fix is employed, the plug in doesn't work any more. type in the "domain.ext/stats" in the browser and you get sent to the main page of your website instead of dreamhost stats.

    *sigh*

  17. stonegauge
    Member
    Posted 7 years ago #

    The proper way to use the HTAccess file fix for dreamhost stats can be found here:

    http://discussion.dreamhost.com/showflat.pl?Cat=&Board=3rdparty&Number=43618&page=0&view=collapsed&sb=5&o=14&part=1#Post43627

Topic Closed

This topic has been closed to new replies.

About this Topic