WebFaction
Community site: login faq

I've got a static site which I want to mask the .html pages in the URL.

I've insert this htaccess rule:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html

but now instead of rendering the page, it redirects (via the same page with an ending slash) which in turn redirects to the .html page. Why is this happening? Is there another setting somewhere which is overwriting the .htaccess in this instance .

asked 03 Nov '13, 20:15

thomas
112
accept rate: 0%

Could you please try this version?

Options +FollowSymLinks -MultiViews

DirectorySlash Off RewriteEngine On RewriteCond %{SCRIPT_FILENAME}/ -d RewriteCond %{SCRIPT_FILENAME}.html !-f RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L] RewriteCond %{ENV:REDIRECT_STATUS} ^$ RewriteRule ^(.+).html$ /$1 [R=301,L] RewriteCond %{SCRIPT_FILENAME}.html -f RewriteRule [^/]$ %{REQUEST_URI}.html [QSA,L]

(04 Nov '13, 17:00) waynek

This rule will work, I just tested it.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]
permanent link

answered 04 Nov '13, 17:01

johns ♦♦
5.3k212
accept rate: 23%

Could you please try this version?

Options +FollowSymLinks -MultiViews

DirectorySlash Off

RewriteEngine On
RewriteCond %{SCRIPT_FILENAME}/ -d
RewriteCond %{SCRIPT_FILENAME}.html !-f
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^(.+)\.html$ /$1 [R=301,L]

RewriteCond %{SCRIPT_FILENAME}.html -f
RewriteRule [^/]$ %{REQUEST_URI}.html [QSA,L]
permanent link

answered 04 Nov '13, 17:01

waynek
4254
accept rate: 27%

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:

×74
×33
×9

question asked: 03 Nov '13, 20:15

question was seen: 1,718 times

last updated: 04 Nov '13, 17:01

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 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