Recent Posts
- (09/10) Fixing Warning: the ECDSA host key for 'github.com' differs from the key for the IP addressTAGS:Web Server Admin
- (12/26) CakePHP 3 - Getting List of Column Definitions from a Table (like schema())TAGS:CakephpCake3
- (09/14) Change Order of Loaded Behaviors in CakePHP 3TAGS:Cake3CakephpWeb ProgrammingPhp
- (05/29) CakePHP 3 - Accept JSON Header Only Working When Debug FalseTAGS:Web ProgrammingCakephpCake3
- (05/23) Remove All Events from Google Calendar (Reset Calendar)TAGS:Web ProgrammingPhp
- (11/08) Google Tag Manager (GTM) Not Firing Default PageView EventTAGS:Web ProgrammingJavascriptGoogle Tag Manager
- (10/13) In PHP, how do you get __toString() Magic Method Result without calling echo?TAGS:CakephpCake3Cakephp 13PhpWeb Programming
- (11/14) Getting output from shell_exec() at all timesTAGS:Web ProgrammingWeb Server Admin
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 34,524 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:
- 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
Comments for this Posting
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.
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!
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.
Sorry, comments are closed for this posting.
Please Email Kevin if you have any questions. Thanks!
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