Filip Sikora
Filip Sikora

Reputation: 61

redirecting with htaccess causes too many redirects

The website I'm working on is using some cms. I need to add a static website to this. When I put mypage.html in the main directory and go to www.website.com/mypage.html it works. I would like the page to be accessible without '.html' ending. I experimented with editing htaccess files but always end up with error of too many redirections.

What I entered were various combinations, for example

Redirect 301 http://website.com/mypage http://website.com/mypage.html

The htaccess file I'm using looks like this:

:Location /*.php
Use php54
:Location

RewriteEngine On



DirectoryIndex index_prod.php
Options -Indexes

RewriteRule ^.*\.(css|png|swf|js|gif|jpeg|jpg|flv|pdf|doc)$ - [L]
RewriteRule ^net2ftp - [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

#RewriteRule ^/?$ plug.html [L]

#RewriteCond %{REQUEST_URI} !=/
RewriteRule ^/?.* index_prod.php


I'm looking for tips or to be explicitly told what and where to put in htaccess file to make it work (if it's possible)

Upvotes: 1

Views: 71

Answers (1)

RavinderSingh13
RavinderSingh13

Reputation: 133428

Could you please try following, considering that you want without extension file URLs to be served by html extension files. Also since you didn't mention any specific condition before RewriteRule hence that redirection errors are coming to it, because its keep on redirecting in lack of any condition/check's presence(till its maximum redirection limit is crossed).

RewriteEngine On
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)$ /$1.html [NC,L]

Upvotes: 2

Related Questions