MainelyDesign.com Blog

Network Solutions' Flawed .htaccess and Mod_Rewrite Rules Implementation

Posted on 08/06/2009 at 02:38 pm by Kevin Wentworth
Viewed 33,757 times | 7 comments

I can't believe it!  I spent hours trying to get the mod_rewrite rules working in .htaccess on Network Solutions' servers.  Everything I tried didn't work.  Using the default .htaccess (from Cake distribution) failed.  I've used the distribution on several servers and never had any issue with the rewrite rules.  However, Network Solutions's mod_rewrite works differently than [all] other servers.

The target and destination file have to exist

Wait, the target file has to exist?  That's right.  You actually need to have a target file, specifically each url being requested, in place for each rewrite rule (even if it's a dummy or 0kb file).  This is straight from Network Solutions' server admin. In order for mod_rewrite rules to work on their servers, you need a target file.

That is completely ridiculous! I use .htaccess so I can have 1 file that "routes" all requests.  Why would I ever want to make dummy/placeholder files? The answer- never!  Just look at Drupal, Cake, Joomla, any CMS uses .htaccess this way, at least if you want SEO friendly links.

Solved by Using a 404 ErrorDocument handler

The tech at Network Solutions said he ran into this the other day (I'm surprised it doesn't come up more...).  He fixed it by using an ErrorDocument handler in the .htaccess file.  Wouldn't you know it worked!  Instead of the Cake default, use this as the .htaccess in your web root:

  1. RewriteEngine On
  2. ErrorDocument 404 /index.php #don't you dare forget that slash on Network Solutions

UPDATE: It's not REALLY working (8/11/2009)

I knew it was too good to be true.  I accessed the web site from my BlackBerry and I got a 404 error.  When I got home, I tried it out and Firebug was reporting 404 error headers for all requests.  Although the web site appears to work on the surface, the 404 errors will be detrimental to search engine rankings (SERPs). Not good!

Symptons that this could be happening to you

On all IE browsers I was getting a generic error message at the bottom of each page:

  1. OK
  2.  
  3. The server encountered an internal error or misconfiguration and was unable to complete your request.
  4.  
  5. Please contact the server administrator, [no address given] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
  6.  
  7. More information about this error may be available in the server error log.

In FireFox most pages would load OK, but every few page loads FF would prompt me to Save or Open the file, or, it would show a white screen with black text source code. WTF?  It almost looks like an extra request for each file and some HTTP headers are getting jammed into your file.  No wonder FF wouldn't render it.  Here's what one of those files looked like:

  1. ed the error.</p>
  2. <p>More information about this error may be available
  3. in the server error log.</p>
  4. </body></html>
  5.  
  6. 0
  7.  
  8. HTTP/1.1 200 OK
  9. Date: Tue, 04 Aug 2009 19:33:21 GMT
  10. Server: Apache/2.2.8 (Unix) FrontPage/5.0.2.2635
  11. X-Powered-By: PHP/5.2.6
  12. Expires: Thu, 19 Nov 1981 08:52:00 GMT
  13. Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
  14. Pragma: no-cache
  15. Set-Cookie: debug_cookie=36; expires=Wed, 05-Aug-2009 19:33:21 GMT
  16. Connection: close
  17. Transfer-Encoding: chunked
  18. Content-Type: text/html
  19.  
  20. 636e
  21.  
  22. <html><head><title>
  23. // YOUR HTML DOC HERE ... then more crap
  24.  
  25. </body>
  26. 0
  27.  
  28. 1f4
  29. <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
  30. <html><head>
  31. <title>200 OK</title>
  32. </head><body>
  33. <h1>OK</h1>
  34. <p>The server encountered an internal error or
  35. misconfiguration and was unable to complete
  36. your request.</p>
  37. <p>Please contact the server administrator,
  38.  [no address given] and inform them of the time the error occurred,
  39. and anything you might have done that may have
  40. caused the error.</p>
  41. <p>More information about this error may be available
  42. in the server error log.</p>
  43. </body></html>
  44.  
  45. 0

Network Solutions' Implementation of .htaccess Sucks

I hope this helps all the people struggling to get .htaccess, mod_rewrite, and RewriteRule working on Network Solutions.  If it doesn't work, try some of the other suggestions I read:

  • Try removing the <IfModule mod_rewrite.c> and </IfModule> tags (Network Solutions apparently runs their PHP as CGI not an apache module)
  • Try setting RewriteBase /  (this helped make the rewrite rule work, but didn't eliminate those garbage requests)
  • Or, you can set your RewriteRule ^(.*)$ /index.php?url=$1 (see that slash in front of index.php?)
  • Or, you can completely remove all files and just have the most simple rewrite rule and you'll still get the freaking phantom error message

Network Solutions only saw the error ONCE

No kidding, they couldn't ever see this error.  I figured they'd send back a 'It's your code' response, but actually gave me the courtesy of a call back.  What's weird is that EVERY time I would load the page in IE I'd see the error (except going to the webroot: / or index.php) and now I know why- the target and destination file existed.  Oh man!

Cheers, (and boy do I need a beer after that one)

-Kevin Wentworth

Bookmark and Share

Tags for Network Solutions' Flawed .htaccess and Mod_Rewrite Rules Implementation

404 Errors | Apache | Htaccess | Internet Explorer | Firefox | Web Programming | Vendors | Seo | Web Server Admin | Cakephp

Comments for this Posting

Posted by Wolfgang Bruckner

on 8/7/10

Having the same problems with several joomla sites that had to be moved to an NWS-Unix-VServer, thanks for this report, I'll try some of your suggestions right away.

http://www.shiftup-blog.de

Posted by Scott

on 14/10/10

Hi Kevin, hope you can help me. I'm dealing with Network Solutions right now on a Wordpress site. Site works fine with permalinks OFF. Once I turn them on the site throws a 500 forbidden error.

Any suggestions?

here is my htaccess

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]


# END WordPress

Posted by Scott

on 14/10/10

Found solution.

1. Removed IfModule
2. Added "/" in front if index.php.

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^/index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]


# END WordPress

Thank you!. Anyone else having issues with Wordpress on Network Solutions just copy that htaccess file and you'll be golden.

http://scottfoley.net

Posted by Mike Munsie

on 18/1/11

This has helped me out on so many levels! I have been working on a Network Solutions server and basically kept getting the same phantom error. I was going mad thinking there was an error in my framework rather than the server itself. I called tech support only for them to tell me that it's my session variables (which I had none being used) and that it was a browser problem (lol) on my end.

So I did a test, did a "hello world" with mod-rewrite on and basically it kept messing up. This told me that it wasn't my framework and that something was wrong with the way the server handled my .htaccess file. So I did some googling, read this blog...

and what did I learn from this blog that solved everything?

RewriteBase /

THANKS!

http://mikemunsie.com

Posted by David Leary

on 31/1/11

wow finally thank you!

had that stupid ok error you mentioned and tore my hair out trying to figure out why it was happening. i just added RewriteBase / to .htaccess file and everything is A ok

Posted by Ada

on 12/2/11

I've had the same problem. My site crashes every third click. NS tech support tried, but ended up telling me that it was a Firefox plug in problem. I'm looking for another server provider. Any suggestions.

Posted by Duck

on 31/10/11

Thanks a lot, this totally helped solve my problem quickly!

Sorry, comments are closed for this posting.

Please Email Kevin if you have any questions. Thanks!

Meet Site Avenger - Hosted Content Management System

Powered By: Site Avenger | Site Production: Saco Design