homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

Looking for .htaccess FAQ
sorry to be a pain

 1:25 am on Mar 4, 2003 (gmt 0)

Spent a couple of days hunting round WW looking for a beginners' guide to .htaccess, but obviously my site searching skills aren't up to it at the mo. Could someone direct me in the right direction? I've verified with my server admin that .htaccess is allowed, configured my FTP program to display the file properly, but am having trouble getting my first test file to fire up. I'm king of the 500 internal server errors at the moment.



 1:31 am on Mar 4, 2003 (gmt 0)

Are you referring to this?

An Introduction to Redirecting URLs on an Apache Server [webmasterworld.com]

it is in the library, the link is right beside the moderator's name in each forum.

<added>gotcha jim ;)

[edited by: jatar_k at 1:33 am (utc) on Mar. 4, 2003]


 1:32 am on Mar 4, 2003 (gmt 0)


Check out the Apache mod_rewrite documentation [httpd.apache.org], and the URL Rewriting Guide linked at the top of that document.

Also, we have this Introduction to mod_rewrite [webmasterworld.com] thread right here on WebmasterWorld.



 1:43 am on Mar 4, 2003 (gmt 0)

Thanks.. those will keep me quiet for a bit :) much appreciated.


 1:52 am on Mar 4, 2003 (gmt 0)


No problem... Just remember, start small. For example, redirect a non-existent URL to your home page as an initial experiment:

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^no\_such\_file\.html$ /index.html [R=301,L]

Then request that non-existent "no_such_file.html" page in your browser, and you should get index.html instead.
When that works, build up from there.



 2:56 am on Mar 4, 2003 (gmt 0)

Sorry guys, thanks for your responses, but really having trouble here..

trying out a custom error page for starters..

.htaccess file, created in editpad lite

(plain text editor very similar to windows notepad):
(tried using windows wordpad too):

ErrorDocument 404 /error.html[carriage return]

saved as type:
tried all the following:
text file (*.txt)
all files (*.*)
perl file (*.pl)
unicode text document (*.*)

checked I saved it as .htaccess , not .htaccess.txt or anything like that

uploaded to root of my apache/linux server using cute FTP in ASCII mode;

checked with server admin; they say yep .htaccess supported;

uploaded error.html to root, very basic html doc, checked it displays ok when called directly;

... try accessing site;I'm just getting a 500 internal server error every time.

Any ideas most appreciated, I bet it's something really simple I'm messing up on.. I remember going through something very similar first time I tried to use perl..


 3:01 am on Mar 4, 2003 (gmt 0)

uploaded to root of my apache/linux server using cute FTP in ASCII mode

Sounds like you're doing all the right things. I'm sure you've probably checked this, just in case, check the permissions on the file.

Give it say 644. Not familiar with cute FTP but if it were to set permissions incorrectly, you could indeed get the dreaded 500 while doing everything else correctly.


 3:08 am on Mar 4, 2003 (gmt 0)

Aye, tried 644, 777, 755 to no avail.

Server admin suggested using the server path


rather than just plain old


but no, no joy.

I even tried an absolute path


again, the dreaded..

I have several accounts with this hosting provider, subscribed at different times; they all fail in the same way.

I'm stumped!

I can feel another email to the server admin coming on. They're a bit variable in their response speed, hopefully they've not been out on the beer this evening!


 3:14 am on Mar 4, 2003 (gmt 0)


Nothing wrong with what you did. Check the following, then contact host and complain.

Verify that the file is named .htaccess on your server, and that it's priveleges are set to allow read access. chmod 444 (Owner:read, Group:Read, World:Read) should work.

Another thought... What does your raw error log say? This can often be very helpful.

It sounds like your host needs to add an AllowOverride [httpd.apache.org] All directive to your (virtual) server to enable your .htaccess to function. If they won't do this, or offer you a lower level of AllowOverride, you should begin looking for a new host.



 3:52 am on Mar 4, 2003 (gmt 0)

Thanks for your help everyone; jdMorgan, 444 didn't do the trick (worth a go though, eh) so I've mailed the admin & asked about the Allow Override, just hope to God it doesn't turn out I forgot something daft. Wouldn't be the first time ;-)

Cheers Guys, Gals


 3:56 am on Mar 4, 2003 (gmt 0)

Server admin suggested using the server path


That would not work for custom error documents. Either a local file, as you had it defined, a qualified URL or text can be used. Not the path to a file.

Do you know anyone who has a hosting account elsewhere where you could try the .htaccess file. If it works there then that will give you more to go on when you contact your host.


 4:02 am on Mar 4, 2003 (gmt 0)

marcs: note: a fully qualified path _is_ a local file.

it's even highly recommended to use the complete path of the local file to let the errordocument setting work side wide in subdirectories, too.

[edited by: hakre at 4:16 am (utc) on Mar. 4, 2003]


 4:10 am on Mar 4, 2003 (gmt 0)

Good point marcs, I have hosting eleswhere so that's something I could test out. "now why didn't I think to do that"..

Second thoughts, no don't answer that. I might not like the answer lol


 4:14 am on Mar 4, 2003 (gmt 0)

marcs: note: a fully qualified path _is_ a local file.

Agreed, I meant "local file" as in relative to DocumentRoot. Given that we are talking about .htaccess/Apache, I was thinking in those terms.

The file path would not be the same as it's path relative to DocumentRoot. .htaccess would look for the file relative to DocumentRoot.


 4:32 am on Mar 4, 2003 (gmt 0)

Warning - Using anything other than the local URL-path formats given in the Apache Core Features ErrorDocument documentation [httpd.apache.org] will cause the server to return a 302-Moved (redirect) status code, instead of the desired 404-Not Found code. This can cause major problems, one of which is that your error document can get indexed and listed by search engines. ga_ga had it right the first time.



 1:30 pm on Mar 4, 2003 (gmt 0)

Guys, thank you for all your help yesterday.

Just received an email from server admin.

"Sorry, we can't allow you to change the 404's; it's a security issue. Let us know which of your pages you want to use as the 404 & we'll set it up server-side for you"

Paraphrasing my response.
"Cheers. What the!&$% *can* I do with .htaccess then, without your holding my hand, what with you already having said the feature is supported?"

I've gently suggested they provide a FAQ..

Chuckle. These guys take the biscuit sometimes, but I must say in their defence their performance in terms of price and uptime tends to outweigh the downsides, so I guess I'll still stick with them. Bit annoying though to be told one thing, spend God knows how long in a futile attempt to get something working, and drag a load of others' time into it into the bargain, only to be told later "Actually...."


 6:03 am on Mar 5, 2003 (gmt 0)

Then in this case i have the same situation as gaga - no wonder my redirects doesn't work.
So for JD's comments on this "It sounds like your host needs to add an AllowOverride All directive to your (virtual) server to enable your .htaccess to function. If they won't do this, or offer you a lower level of AllowOverride, you should begin looking for a new host. "
I've tried the "Limit" option & it works, so what other options are available with this low level access?

Allow use of the authorization directives (AuthDBMGroupFile, AuthDBMUserFile, AuthGroupFile, AuthName, AuthType, AuthUserFile, Require, etc.).
Allow use of the directives controlling document types (AddEncoding, AddLanguage, AddType, DefaultType, ErrorDocument, LanguagePriority, etc.).
Allow use of the directives controlling directory indexing (AddDescription, AddIcon, AddIconByEncoding, AddIconByType, DefaultIcon, DirectoryIndex, FancyIndexing, HeaderName, IndexIgnore, IndexOptions, ReadmeName, etc.).
Allow use of the directives controlling host access (Allow, Deny and Order).
Allow use of the directives controlling specific directory features (Options and XBitHack).
? ?


 6:20 am on Mar 5, 2003 (gmt 0)


Basically, your host can pick-and-choose which Options you are allowed to change (Override), so the answer to your question is, "it depends".

However, I just flat won't deal with a host that won't give me AllowOverride All priveleges, or that does a bad job handling site security issues, or that allows servers to go down for more than a few (more than 3) minutes per year. There are simply too many decent hosting companies out there to mess with second-rate service. I pay a little more (nothing if compared to revenue) for decent service that makes my life easier, and don't sweat the fact that I'm paying a whole extra $5 or $10 a month.

I don't know if I answered the question you intended, but try each of the directive types that interest you, and see if they work.



 8:19 am on Mar 5, 2003 (gmt 0)

Oh thanks, I just installed Apache & was reading through the conf file. Yah get wat u mean by allowing which & wat. Basically i think anyone wanting to ask anything about apache related stuff should just download the thing & run it to see how things work.
Lazy bugers like me. :)


 9:13 am on Mar 5, 2003 (gmt 0)

Try changing it so that it redirects to 'error404.html' and not '/error404.html'. See if that works, it works on my host, but as soon as I put in the forward slash, it fails for some reason.

If it does work, you need to put a .htaccess file in your subdirs to point to '../error404.html'.


 11:07 pm on Mar 6, 2003 (gmt 0)

ack. I need a new host. Anyone suggest a very rough guide to current prices?


 8:16 pm on Mar 9, 2003 (gmt 0)

Turns out they won't allow custom 404 via .htaccess after all. They did try setting me up via 'the virtual server configuration' - by which I have this file 404.shtml in root, which gets displayed as the 404 error page; I can use whatever html in it as long as I keep the filename the same. Don't quite know what the 'virtual server configuration' entails, they say it's a security thing.. but I'm having some very weird behaviour. Lynx, Opera display the custom 404 content fine, but IE ignores it and puts up a standard 404 page. Interestingly, the last two lines on the 404 page that gets displayed by IE are:

HTTP 404 - File not found
Internet Explorer

so, I'm suspecting this is coming from within the browser, not their server.

If I type in an invalid filename for WW, though, using IE, I get the forum's custom 404 - the 'scream' painting - so I'm totally confused.

What, in their linux/apache (virtual?) setup, could cause this weirdness?

Is it maybe that if an actual 404 code is returned in the http headers to IE, it's tough luck, you get it's own error page, and not any other associated content the server sent? That's a bit off eh? Wonder if the mysterious 'virtual server configuration' would allow for not sending a 404 if that were the case..

I'm beginning to get rather shy of even trying to ban email harvesters / bad robots using .htaccess lol

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved