127 lines
4.4 KiB
Plaintext
127 lines
4.4 KiB
Plaintext
# ----------------------------------------------------------------------
|
|
# Start rewrite engine
|
|
# ----------------------------------------------------------------------
|
|
|
|
# Turning on the rewrite engine is necessary for the following rules and features.
|
|
|
|
<IfModule mod_rewrite.c>
|
|
RewriteEngine On
|
|
</IfModule>
|
|
|
|
# ----------------------------------------------------------------------
|
|
# Suppress or force the "www." at the beginning of URLs
|
|
# ----------------------------------------------------------------------
|
|
|
|
# The same content should never be available under two different URLs - especially not with and
|
|
# without "www." at the beginning, since this can cause SEO problems (duplicate content).
|
|
# That's why you should choose one of the alternatives and redirect the other one.
|
|
|
|
# By default option 1 (no "www.") is activated. Remember: Shorter URLs are sexier.
|
|
# no-www.org/faq.php?q=class_b
|
|
|
|
# If you rather want to use option 2, just comment out all option 1 lines
|
|
# and uncomment option 2.
|
|
# IMPORTANT: NEVER USE BOTH RULES AT THE SAME TIME!
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# <IfModule mod_rewrite.c>
|
|
# RewriteCond %{HTTPS} !=on
|
|
# RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
|
|
# RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
|
|
# </IfModule>
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------
|
|
# Add/remove trailing slash to (non-file) URLs
|
|
# ----------------------------------------------------------------------
|
|
|
|
# Google treats URLs with and without trailing slashes separately.
|
|
# Forcing a trailing slash is usually preferred, but all that's really
|
|
# important is that one correctly redirects to the other.
|
|
|
|
# By default option 1 (force trailing slash) is activated.
|
|
# http://googlewebmastercentral.blogspot.com/2010/04/to-slash-or-not-to-slash.html
|
|
# http://www.alistapart.com/articles/slashforward/
|
|
# http://httpd.apache.org/docs/2.0/misc/rewriteguide.html#url Trailing Slash Problem
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
<IfModule mod_rewrite.c>
|
|
RewriteCond %{REQUEST_FILENAME} !-f
|
|
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/|#(.*))$
|
|
RewriteRule ^(.*)$ /$1/ [R=301,L]
|
|
</IfModule>
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# Option 2:
|
|
# Rewrite "domain.com/foo/ -> domain.com/foo"
|
|
|
|
#<IfModule mod_rewrite.c>
|
|
# RewriteRule ^(.*)/$ /$1 [R=301,L]
|
|
#</IfModule>
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------
|
|
# Prevent 404 errors for non-existing redirected folders
|
|
# ----------------------------------------------------------------------
|
|
|
|
# without -MultiViews, Apache will give a 404 for a rewrite if a folder of the same name does not exist
|
|
# e.g. /blog/hello : webmasterworld.com/apache/3808792.htm
|
|
|
|
Options -MultiViews
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------
|
|
# custom 404 page
|
|
# ----------------------------------------------------------------------
|
|
|
|
# You can add custom pages to handle 500 or 403 pretty easily, if you like.
|
|
ErrorDocument 404 /404.html
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------
|
|
# UTF-8 encoding
|
|
# ----------------------------------------------------------------------
|
|
|
|
# use utf-8 encoding for anything served text/plain or text/html
|
|
AddDefaultCharset utf-8
|
|
|
|
# force utf-8 for a number of file formats
|
|
AddCharset utf-8 .html .css .js .xml .json .rss
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------
|
|
# A little more security
|
|
# ----------------------------------------------------------------------
|
|
|
|
|
|
# Do we want to advertise the exact version number of Apache we're running?
|
|
# Probably not.
|
|
## This can only be enabled if used in httpd.conf - It will not work in .htaccess
|
|
# ServerTokens Prod
|
|
|
|
|
|
# "-Indexes" will have Apache block users from browsing folders without a default document
|
|
# Usually you should leave this activated, because you shouldn't allow everybody to surf through
|
|
# every folder on your server (which includes rather private places like CMS system folders).
|
|
Options -Indexes
|
|
|
|
|
|
# Block access to "hidden" directories whose names begin with a period. This
|
|
# includes directories used by version control systems such as Subversion or Git.
|
|
<IfModule mod_rewrite.c>
|
|
RewriteRule "(^|/)\." - [F]
|
|
</IfModule>
|
|
|
|
<% if @site.config[:redirects] %>
|
|
# Set up URL redirects<% @site.config[:redirects].each do |h| %>
|
|
Redirect 301 <%= h[:from] %> <%= h[:to] %>
|
|
<% end %><% end %>
|