View Full Version : Finicky htaccess files -- am I doing something wrong?
keyon
01-02-2012, 04:01 PM
Sometimes when I add a new line of code to my htaccess file, the entire site will go down, and produce a 500 error code for the url.
So I simply go back to the htaccess file, remove whatever I added that caused the problem, and then upload the corrected file.
However, this usually does not fix the problem (at least not immediately). I continue to get the 500 errror code, regardless of the fact that I've changed the htaccess file back to its original state.
Is this simply a matter of my web server (apache) having somewhat of time delay in recognizing the corrected htaccess file that I upload?
My web host tech support tells me no --- and that by simply removing the offending code, everything should work as it did before. However, during the course of the conversation, they also say something to the effect of "I renamed your htaccess file, and now it works okay. So it must have been something you put in the code."
This makes me think that it is a caching issue of some sort. Yes? No?
deepsand
01-02-2012, 05:33 PM
A 500 indicates a problem with the web server itself.
From HTTP Error 500 Internal server error (http://www.checkupdown.com/status/E500.html):
... the Web server should generate some kind of internal error log which gives more details of what went wrong. It is up to the operators of the Web server site to locate and analyse these logs.
HTMLBasicTutor
01-02-2012, 10:52 PM
What are you using to edit the .htaccess file?
williamc
01-03-2012, 02:04 AM
What are you using to edit the .htaccess file?
This would have been my question as well, as some programs insert hidden chars that can foul the .htaccess easily, and would indeed cause a 500 error from the web server.
keyon
01-03-2012, 10:26 AM
What are you using to edit the .htaccess file?
I use notepad.
However, I have on occasion tried editing this file directly from the file manager in control panel.
...some programs insert hidden chars that can foul the .htaccess easily, and would indeed cause a 500 error from the web server.
This sounds like a good explanation, since as I mentioned, changing the contents of the file back to its original state doesn't seem to remove the error. Something must be happening as a result of simply republishing the file -- something I can't really see. Perhaps the editing feature in my file manager is adding the hidden characters?
HTMLBasicTutor
01-03-2012, 01:28 PM
Try FTPing it back into the webspace instead of using your control panel to upload or edit.
keyon
01-03-2012, 01:52 PM
Try FTPing it back into the webspace instead of using your control panel to upload or edit.
Yeah...I'll try that next time. Well, if there is a next time, anyway. I'm half afraid to even touch that file anymore :-)
On a related question: The only reason I've been making changes to my htaccess file is to add redirects for missing pages that GWT reports to me -- pages that I've moved or deleted, and also pages from external sites that messed up the url in their link to me. Should I even bother trying to redirect all this stuff?
williamc
01-03-2012, 02:23 PM
Try FTPing it back into the webspace instead of using your control panel to upload or edit.
and make 100% sure that your FTP client uploads it in ASCII mode, not binary, or you will have the same results.
williamc
01-03-2012, 02:25 PM
Should I even bother trying to redirect all this stuff?
Being that those old pages may have carried some PR around, and even moreso if they may have sent a little traffic via longtail terms, yes.
radhika
01-04-2012, 07:33 PM
1. Always edit htaccess file as htaccess.txt on your computer.
2. Use notepad like you said.
3. Upload htaccess.txt in ASCII mode to your server and THEN CHANGE to .htaccess in your ftp program.
4. If you downloading .htaccess file to your computer in any case, (while your ftp program prompts for file name) change it to htaccess.txt
.
Clint1
01-05-2012, 07:42 AM
I always edit my htaccess file via the cPanel File Manager and have never had any problems. It's also the fastest simplest way. When I've gotten the '500 server error' it was always due to an error on my part in the coding, as in something not acceptable or didn't do a full copy 'n paste of something, etc.
keyon
01-15-2012, 01:49 PM
1. Always edit htaccess file as htaccess.txt on your computer.
2. Use notepad like you said.
3. Upload htaccess.txt in ASCII mode to your server and THEN CHANGE to .htaccess in your ftp program.
4. If you downloading .htaccess file to your computer in any case, (while your ftp program prompts for file name) change it to htaccess.txt
.
Thanks, radhika. Your method seems to be foolproof. Works like a charm for me.
Clint1
01-15-2012, 02:24 PM
Thanks, radhika. Your method seems to be foolproof. Works like a charm for me.
That's a lot of steps. You don't have cPanel? See post #11 above. That's by far the quickest simplest way.
keyon
01-16-2012, 09:44 AM
Thanks, Clint1,
Yes, I'd much rather make the changes from cpanel (in the edit window). I probably didn't do enough experimenting to determine the exact source of the problem. But it does make sense that editing the htaccess file directly from cpanel shouldn't really affect the properties of the file itself.
Clint1
01-16-2012, 10:30 AM
Thanks, Clint1,
Yes, I'd much rather make the changes from cpanel (in the edit window). I probably didn't do enough experimenting to determine the exact source of the problem. But it does make sense that editing the htaccess file directly from cpanel shouldn't really affect the properties of the file itself.
As long as you use the File Manager it's not a problem. However, do not try and make changes to the htaccess file via the cPanel GUI interface, such as clicking the "IP Deny" icon or any "Redirects" icons which sort of edit the file for you. Last time I checked, those areas are really buggy and will screw up/overwrite any custom lines you manually added to the file, and they also can introduce buggy code. So just open the file in the File Manager do your typing or cut/copy 'n paste there. (cPanel is aware of this and have refused to do anything about it). Needless to say, be sure you always have a backup of the file.
keyon
01-16-2012, 10:38 AM
As long as you use the File Manager it's not a problem. However, do not try and make changes to the htaccess file via the cPanel GUI interface
When I talk about editing the htaccess file via cPanel, I guess I'm talking about going into the file manager, selecting the file, and then clicking "edit code" at the top of the page. Is this the same GUI interface you are talking about?
Clint1
01-16-2012, 11:48 AM
When I talk about editing the htaccess file via cPanel, I guess I'm talking about going into the file manager, selecting the file, and then clicking "edit code" at the top of the page. Is this the same GUI interface you are talking about?
(This website is SOOOO SCREWED UP it's PATHETIC. Waiting TEN MINUTES for a page to load is unforgivable!) No, what you're doing is safe. The GUI interface is, like I said, the icons layout on your cPanel home/main page.
keyon
01-16-2012, 11:54 AM
Thanks, Clint1. That will make things much easier from now on.
Clint1
01-16-2012, 01:25 PM
Sure. ;) .........
Clint1
02-10-2012, 06:56 AM
The following line in your first post caught my eyes,
Its strange to hear that despite the removal of newly added part in the htaccess the site isn't recognising it instantly. I think you should speak to your host about this, its a strange behaviour. The server logs should help understand whats causing the delay.
I haven't slept and I can't remember all about this thread, but I believe some have said it's some kind of "caching issue". It's not rare, I've also seen it happen. If you look at the end of his post you'll see he also alluded to that.