Редирекс c index.html на / (с проверкой на наличие GZ файла)

_Vlad_
На сайте с 18.06.2011
Offline
22
794

Добрый день,

пробую реализовать следующую логику:

при запросе http://townden.com/index.html должен происходить редирект на http://townden.com/ , затем на основании DirectoryIndex (в httpd.conf) ищутся index.htm, index.html, ...

На сервере лежит index.htm.gz файл, который (через условие <FilesMatch .*\.(htm)>) должен отдаться посетителю

но на самом деле выдается 404 страница

сори за детальное изложение мыслей, т.к. сам новичек в .htaccess, пытаюсь выстроить картину происходящего ... третий день колдую с условиями, но не пойму где ошибаюсь

Options -Indexes


ErrorDocument 404 /404.html

RewriteEngine on
#RewriteBase /

# redirect from http://www.townden.com/index.html to http://townden.com/
RewriteCond %{HTTP_HOST} ^www.townden.com$ [NC]
RewriteRule ^(.*)$ http://townden.com/$1 [R=301,L]

# redirect from http://townden.com/index.html to http://townden.com/
RewriteCond %{HTTP_HOST} ^townden\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.townden\.com$
RewriteRule ^index\.html$ "http\:\/\/townden\.com\/" [R=301,L]



# used to send htm.gz file (if exists) instead of htm
AddEncoding gzip .gz
<Files *.htm.gz>
ForceType text/html
</Files>
<FilesMatch .*\.(htm)>
# ATTANTION! don't disable "RewriteEngine On" it must be presented to work correctly!
RewriteEngine On

# next two strings important to avoid loop (500 Internal Server Error)
#
RewriteCond %{ENV:REDIRECT_FINISH} !^$
RewriteRule ^ - [L]

RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{REQUEST_FILENAME}.gz -f
# IMPORTANT set E=FINISH:1 to avoid loop (500 Internal Server Error)
RewriteRule ^(.*)$ $1.gz [L,E=FINISH:1]
</FilesMatch>

# used to send html.gz file (if exists) instead of html
AddEncoding gzip .gz
<Files *.html.gz>
ForceType text/html
</Files>
<FilesMatch .*\.(html)>
# ATTANTION! don't disable "RewriteEngine On" it must be presented to work correctly!
RewriteEngine On

# next two strings important to avoid loop (500 Internal Server Error)
#
RewriteCond %{ENV:REDIRECT_FINISH} !^$
RewriteRule ^ - [L]

RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{REQUEST_FILENAME}.gz -f
# IMPORTANT set E=FINISH:1 to avoid loop (500 Internal Server Error)
RewriteRule ^(.*)$ $1.gz [L,E=FINISH:1]
</FilesMatch>

заранее спасибо за помощь,

Влад

Авторизуйтесь или зарегистрируйтесь, чтобы оставить комментарий