WebFaction
Community site: login faq

I'm setting up a static/cgi/php site (all static HTML pages, nothing else) and need some help with my .htaccess file.

Here's my current .htaccess:

#No directory listings Options -Indexes

Custom error pages

ErrorDocument 404 /errors/404.html

ErrorDocument 500 /errors/500.html

Dump www

RewriteEngine On

Rewritebase /

RewriteCond %{HTTP_HOST} !^mysite.com$ [NC]

RewriteRule ^(.*)$ http://mysite.com/$1 [L,R=301]

Remove file extensions from .html files

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME}.html -f

RewriteRule ^(.*)$ $1.html

But...

While "mysite.com/pages/about.html" correctly displays that page, "mysite.com/pages/about.html/" displays an unstyled 404 page. (EDIT: This seems down to mangled links to the CSS file.)

"mysite.com/pages/about" correctly displays that page. But "mysite.com/pages/about/" displays an "Internal Server Error" message and a note that "Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.".

What am I doing wrong?

asked 19 Jan '12, 05:55

wagerrard
112
accept rate: 0%

edited 19 Jan '12, 06:19


Hi,

The unstyled 404 page shouldn't be happening unless the /errors/404.html file is missing, or if it's smaller than 512 bytes and you're using an old IE browser. If you can't figure this out, please open a ticket, and we'll take a look.

Regarding removing file extensions from HTML files, there's a better way to do it - turning on MultiViews. You can do this by putting the following line in your .htaccess:

Options +Multiviews

permanent link

answered 19 Jan '12, 06:18

todork
1.2k5
accept rate: 34%

Thanks. Bad CSS links produced the unstlyed pages. I've fixed that and edited my question to reflect it.

"Options +Multiview" works fine.

The "Internal Error Message" display is gone, but adding a backslash -- "mysite.com/newpost/" or "mysite.com/pages/about/" brings up a 404. I want the backslash to disappear and the correct page to display. Off to figure that out.

(19 Jan '12, 06:30) wagerrard

Hi again,

You can try something like this to remove the trailing slash from the URL.

(19 Jan '12, 07:47) todork
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×125
×33

question asked: 19 Jan '12, 05:55

question was seen: 3,876 times

last updated: 19 Jan '12, 07:47

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2020 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM