Recent Posts
- (08/31) Global Mysql Find and Replace with CakePHPTAGS:CakephpDatabaseMysqlExampleSite AvengerTutorialWeb Programming
- (06/23) Difference Between Truncate and Empty (Delete From) in MysqlTAGS:MysqlDatabaseWeb Server AdminUsageSoftwareTruncate
- (05/29) Best Approach to Dynamic Javascript in CakePHP ViewsTAGS:CakephpWeb ProgrammingJqueryUsageExamplePhp
- (05/28) Speeding Up Cakephp's ACL ComponentTAGS:CakephpDatabaseWeb ProgrammingMysqlForum AnswersPhpExample
- (04/20) Best Free Mysql Zip code DatabaseTAGS:Web ProgrammingUsageDatabaseMysqlPhp
- (04/19) Controlling CakePHP Error Handling When Debug = 0TAGS:CakephpWeb ProgrammingSeoPhpMysqlDatabaseExampleTutorial
- (03/24) Cache Results from Query in CakePHPTAGS:CakephpDatabaseWeb ProgrammingUsageExample
- (03/22) Setting Envelope-From in CakePHP's Email ComponentTAGS:CakephpComponentTutorialExamplePhpUsageWeb Programming
Subscribe to my feed
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 1,572 times | 1 comment
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:
- RewriteEngine On
- 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:
- OK
- The server encountered an internal error or misconfiguration and was unable to complete your request.
- 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.
- 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:
- ed the error.</p>
- <p>More information about this error may be available
- </body></html>
- 0
- HTTP/1.1 200 OK
- Server: Apache/2.2.8 (Unix) FrontPage/5.0.2.2635
- X-Powered-By: PHP/5.2.6
- Expires: Thu, 19 Nov 1981 08:52:00 GMT
- Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
- Pragma: no-cache
- Set-Cookie: debug_cookie=36; expires=Wed, 05-Aug-2009 19:33:21 GMT
- Connection: close
- Transfer-Encoding: chunked
- Content-Type: text/html
- 636e
- <html><head><title>
- // YOUR HTML DOC HERE ... then more crap
- </body>
- 0
- 1f4
- <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
- <html><head>
- <title>200 OK</title>
- </head><body>
- <h1>OK</h1>
- <p>The server encountered an internal error or
- misconfiguration and was unable to complete
- your request.</p>
- <p>Please contact the server administrator,
- and anything you might have done that may have
- caused the error.</p>
- <p>More information about this error may be available
- </body></html>
- 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
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

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