I'm trying to get my 404 error page to work, but my htaccess file is preventing it from working. # For security reasons, Option followsymlinks cannot be overridden. #Options +FollowSymLinks Options +SymLinksIfOwnerMatch RewriteEngine on RewriteCond %{HTTP_HOST} ^coolchecks\.net RewriteRule ^(.*)$ http://www.coolchecks.net/$1 [R=permanent,L] DirectoryIndex index.php RewriteBase / RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/ RewriteRule ^index\.php$ http://www.domain.com/ [R=301,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] Redirect /index.html http://www.domain.com/index.php Redirect /specialedition.htm http://www.domain.com/specialedition.php Code (markup): Is there something in this part of the code that is causing that? The purpose of the two rules is to get the domain to redirect to index.php and show domain.com in the url. Thanks!
I've already told you lol. ErrorDocument 404 /404page.html Code (markup): The same with other error pages such as 401, 501, etc if you want. The ErrorDocument 404 part tells your server that this is what you want to serve as an error page for 404 errors and the 404page.html part tells it what. Although the ErrorDocument 404 part is required, you can call the page anything you like; e.g. spacebunny.html, spockwashere.html, anything. ErrorDocument 404 /spacebunny.html Code (markup): If you decide to put your error pages in a subfolder you would do this: ErrorDocument 404 /subfolder/spacebunny.html Code (markup): Here's further reading to get you started: http://www.javascriptkit.com/howto/htaccess.shtml So here's your htaccess with added lines for the 401 and 404 error documents. It's also good practice to make sure your site doesn't inadvertently allow someone to view everything in a folder so it's always worth adding: Options -indexes #Your 401 error page ErrorDocument 401 /your401page.html #Your 404 error page ErrorDocument 404 /your404page.html #turn off folder listings Options -Indexes # For security reasons, Option followsymlinks cannot be overridden. #Options +FollowSymLinks Options +SymLinksIfOwnerMatch RewriteEngine on RewriteCond %{HTTP_HOST} ^coolchecks\.net RewriteRule ^(.*)$ http://www.coolchecks.net/$1 [R=permanent,L] DirectoryIndex index.php RewriteBase / RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/ RewriteRule ^index\.php$ http://www.domain.com/ [R=301,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] Redirect /index.html http://www.domain.com/index.php Redirect /specialedition.htm http://www.domain.com/specialedition.php Code (markup):
Do the error pages exist? This bit of code redirects any files or directories that don't exist to the index page. RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] Code (markup): So if they don't exist or they exist in a subfolder and you haven't told it where to find them then your site will go to index.php. Read this: http://forum.mamboserver.com/archive/index.php?t-42366.html and this: http://www.askapache.com/htaccess/mod_rewrite-tips-and-tricks.html
Thank you for explaining this to me. I used this and now it's working fine. Does the code look fine to you? ErrorDocument 404 /404.php # For security reasons, Option followsymlinks cannot be overridden. #Options +FollowSymLinks Options +SymLinksIfOwnerMatch RewriteEngine on RewriteCond %{HTTP_HOST} ^domain\.net RewriteRule ^(.*)$ http://www.domain.net/$1 [R=permanent,L] DirectoryIndex index.php RewriteBase / RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/ RewriteRule ^index\.php$ http://www.domain.net/ [R=301,L] Code (markup):
Yes, it seems okay except you didn't add the line I told you about to prevent folders listing their contents so I can do this:
I've added that now. So let me see if I understand what that does. Any folder that really has no index page will not show the files in it. How do you prevent people from seeing your robots file? I've always thought that was something no one should see. Thanks so much for walking me through this.
Correct. Unfortunately you can't but I wouldn't worry about it. The information in it is of little use to anyone else. You're welcome. Try to read up a bit more on htaccess if you can. You'll find it very useful over time.