seregajd999
@seregajd999
Начинающий веб разработчик))

Как настроить .htaccess файл для Сайта на чистом html?

Привет Всем!
Как настроить .htaccess файл для Сайта на чистом html?
404- страницу?
Если возможно кэш для браузеров.

Я новичок в этом деле(, сильно не ругайте.

Есть вот такие настройки, но не чего не работает(((

<IfModule mod_deflate.c>
  # Compress HTML, CSS, JavaScript, Text, XML and fonts
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/rss+xml
  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
  AddOutputFilterByType DEFLATE application/x-font
  AddOutputFilterByType DEFLATE application/x-font-opentype
  AddOutputFilterByType DEFLATE application/x-font-otf
  AddOutputFilterByType DEFLATE application/x-font-truetype
  AddOutputFilterByType DEFLATE application/x-font-ttf
  AddOutputFilterByType DEFLATE application/x-javascript
  AddOutputFilterByType DEFLATE application/xhtml+xml
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE font/opentype
  AddOutputFilterByType DEFLATE font/otf
  AddOutputFilterByType DEFLATE font/ttf
  AddOutputFilterByType DEFLATE image/svg+xml
  AddOutputFilterByType DEFLATE image/x-icon
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE text/plain
  AddOutputFilterByType DEFLATE text/xml

  # Remove browser bugs (only needed for really old browsers)
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
  Header append Vary User-Agent
</IfModule>


<IfModule mod_expires.c>
	ExpiresActive on

	ExpiresDefault "access plus 1 month"

	# cache.appcache needs re-requests in FF 3.6 (thanks Remy ~Introducing HTML5)
	ExpiresByType text/cache-manifest "access plus 0 seconds"

	# html
	ExpiresByType text/html "access plus 0 seconds"

	# XML
	ExpiresByType text/xml "access plus 0 seconds"
	ExpiresByType application/xml "access plus 0 seconds"

	# RSS
	ExpiresByType application/rss+xml "access plus 1 hour"

	# Favicon
	ExpiresByType image/x-icon "access plus 1 week"

	# Картинки
	ExpiresByType image/gif "access plus 1 month"
	ExpiresByType image/png "access plus 1 month"
	ExpiresByType image/jpeg "access plus 1 month"
	ExpiresByType image/jpg "access plus 1 month"

	# HTC файлы  (например css3pie)
	ExpiresByType text/x-component "access plus 1 month"

	# Нестандартные шрифты сайта
	ExpiresByType application/x-font-ttf "access plus 1 month"
	ExpiresByType font/opentype "access plus 1 month"
	ExpiresByType application/x-font-woff "access plus 1 month"
	ExpiresByType image/svg+xml "access plus 1 month"
	ExpiresByType application/vnd.ms-fontobject "access plus 1 month"

	# CSS и javascript
	ExpiresByType text/css "access plus 1 year"
	ExpiresByType application/javascript "access plus 1 year"

</IfModule>

# Cache-Control браузера 
<ifModule mod_headers.c>
	# 30 дней
	<filesMatch ".(ico|pdf|flv|jpg|jpeg|png|gif|swf)$">
	Header set Cache-Control "max-age=2592000, public"
	</filesMatch>
	# 30 дней
	<filesMatch ".(css|js)$">
	Header set Cache-Control "max-age=2592000, public"
	</filesMatch>
	# 2 дня
	<filesMatch ".(xml|txt)$">
	Header set Cache-Control "max-age=172800, public, must-revalidate"
	</filesMatch>
	# 1 день
	<filesMatch ".(html|htm|php)$">
	Header set Cache-Control "max-age=172800, private, must-revalidate"
	</filesMatch>
</ifModule>

<IfModule mod_setenvif.c>
	#Эта конструкция для говнобраузера
	#Запрет отдачи HTTP-заголовков Vary
	BrowserMatch "MSIE" force-no-vary
	BrowserMatch "Mozilla/4.[0-9]{2}" force-no-vary
</IfModule>




DirectoryIndex index.html

Options +FollowSymLinks


RewriteEngine On
 
ErrorDocument 404 /404.html 

RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
RewriteRule . %1/%2 [R=301,L]

RewriteCond %{REQUEST_URI} ^(.*)/#(.*)$
RewriteRule . %1/%2 [R=301,L]


RewriteCond %{HTTP_HOST} ^www.horror.local$ [NC]
RewriteRule ^(.*)$ http://horror.local/$1 [R=301,L]

# Редирект с index.php/html на сайт
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.(php|html)\ HTTP/
RewriteRule .* / [R=301,L]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP
RewriteRule ^index\.php$ http://horror.local/ [R=301,L]


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


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


RewriteCond %{REQUEST_URI} !(.*)/$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !\..+$
RewriteRule ^(.*)$ $1/ [L,R=301]


RewriteEngine On
RewriteBase /

RewriteCond %{QUERY_STRING} ^(.*)/$
RewriteRule ^(.*)$ /$1?%1 [R=301,L]

RewriteRule ^(.*)/$ /$1 [R=301,L]
  • Вопрос задан
  • 1149 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы