# Apache Server Configs v1.1.0 | MIT License
# https://github.com/h5bp/server-configs-apache
# (!) Using `.htaccess` files slows down Apache, therefore, if you have access
# to the main server config file (usually called `httpd.conf`), you should add
# this logic there: http://httpd.apache.org/docs/current/howto/htaccess.html.
# ##############################################################################
# # URL REWRITES #
# ##############################################################################
# ------------------------------------------------------------------------------
# | Rewrite engine |
# ------------------------------------------------------------------------------
# Turning on the rewrite engine and enabling the `FollowSymLinks` option is
# necessary for the following directives to work.
# If your web host doesn't allow the `FollowSymlinks` option, you may need to
# comment it out and use `Options +SymLinksIfOwnerMatch` but, be aware of the
# performance impact: http://httpd.apache.org/docs/current/misc/perf-tuning.html#symlinks
# Also, some cloud hosting services require `RewriteBase` to be set:
RewriteRule ^(\d+)w(\d+)[-/].*[-/]f(\d+)-.*$ index\.php?id=$1-$2-$3&%{QUERY_STRING} [L]
RewriteRule ^(\d+)w(\d+)[-/]f(\d+)[-/].*$ index\.php?id=$1-$2-$3&%{QUERY_STRING} [L]
RewriteRule ^f(\d+)[-/].*[-/](\d+)w(\d+)[-/].*$ index\.php?id=$2-$3-$1&%{QUERY_STRING} [L]
RewriteRule ^f(\d+)[-/](\d+)w(\d+)[-/].*$ index\.php?id=$2-$3-$1&%{QUERY_STRING} [L]
RewriteRule ^.*[-/]f(\d+)[-/](\d+)w(\d+)[-/].*$ index\.php?id=$2-$3-$1&%{QUERY_STRING} [L]
RewriteRule ^.*[-/]f(\d+)[-/].*[-/](\d+)w(\d+)[-/].*$ index\.php?id=$2-$3-$1&%{QUERY_STRING} [L]
RewriteRule ^.*[-/](\d+)w(\d+)[-/].*[-/]f(\d+)[-/].*$ index\.php?id=$1-$2-$3&%{QUERY_STRING} [L]
RewriteRule ^.*[-/](\d+)w(\d+)[-/]f(\d+)[-/].*$ index\.php?id=$1-$2-$3&%{QUERY_STRING} [L]
RewriteRule ^(\d+)w(\d+)[-/].*[-/]f(\d+)-.*$ index\.php?id=$1-$2-$3&%{QUERY_STRING} [L]
RewriteRule ^(\d+)w(\d+)[-/]f(\d+)[-/].*$ index\.php?id=$1-$2-$3&%{QUERY_STRING} [L]
RewriteRule ^f(\d+)[-/].*[-/](\d+)w(\d+)[-/].*$ index\.php?id=$2-$3-$1&%{QUERY_STRING} [L]
RewriteRule ^f(\d+)[-/](\d+)w(\d+)[-/].*$ index\.php?id=$2-$3-$1&%{QUERY_STRING} [L]
RewriteRule ^.*[-/]f(\d+)[-/](\d+)w(\d+)[-/].*$ index\.php?id=$2-$3-$1&%{QUERY_STRING} [L]
RewriteRule ^.*[-/]f(\d+)[-/].*[-/](\d+)w(\d+)[-/].*$ index\.php?id=$2-$3-$1&%{QUERY_STRING} [L]
RewriteRule ^.*[-/](\d+)w(\d+)[-/].*[-/]f(\d+)[-/].*$ index\.php?id=$1-$2-$3&%{QUERY_STRING} [L]
RewriteRule ^.*[-/](\d+)w(\d+)[-/]f(\d+)[-/].*$ index\.php?id=$1-$2-$3&%{QUERY_STRING} [L]
RewriteRule ^(\d+)w(\d+)[-/].*[-/]f(\d+)-.*$ index\.php?id=$1-$2-$3&%{QUERY_STRING} [L]
RewriteRule ^(\d+)w(\d+)[-/]f(\d+)[-/].*$ index\.php?id=$1-$2-$3&%{QUERY_STRING} [L]
RewriteRule ^f(\d+)[-/].*[-/](\d+)w(\d+)[-/].*$ index\.php?id=$2-$3-$1&%{QUERY_STRING} [L]
RewriteRule ^f(\d+)[-/](\d+)w(\d+)[-/].*$ index\.php?id=$2-$3-$1&%{QUERY_STRING} [L]
RewriteRule ^.*[-/]f(\d+)[-/](\d+)w(\d+)[-/].*$ index\.php?id=$2-$3-$1&%{QUERY_STRING} [L]
RewriteRule ^.*[-/]f(\d+)[-/].*[-/](\d+)w(\d+)[-/].*$ index\.php?id=$2-$3-$1&%{QUERY_STRING} [L]
RewriteRule ^.*[-/](\d+)w(\d+)[-/].*[-/]f(\d+)[-/].*$ index\.php?id=$1-$2-$3&%{QUERY_STRING} [L]
RewriteRule ^.*[-/](\d+)w(\d+)[-/]f(\d+)[-/].*$ index\.php?id=$1-$2-$3&%{QUERY_STRING} [L]
RewriteRule ^v(\d+)[-/].*[-/]b(\d+)-.*$ index\.php?id=$1-$2&%{QUERY_STRING} [L]
RewriteRule ^v(\d+)[-/]b(\d+)[-/].*$ index\.php?id=$1-$2&%{QUERY_STRING} [L]
RewriteRule ^b(\d+)[-/].*[-/]v(\d+)[-/].*$ index\.php?id=$2-$1&%{QUERY_STRING} [L]
RewriteRule ^b(\d+)[-/]v(\d+)[-/].*$ index\.php?id=$2-$1&%{QUERY_STRING} [L]
RewriteRule ^.*[-/]b(\d+)[-/]v(\d+)[-/].*$ index\.php?id=$2-$1&%{QUERY_STRING} [L]
RewriteRule ^.*[-/]b(\d+)[-/].*[-/]v(\d+)[-/].*$ index\.php?id=$2-$1&%{QUERY_STRING} [L]
RewriteRule ^.*[-/]v(\d+)[-/].*[-/]b(\d+)[-/].*$ index\.php?id=$1-$2&%{QUERY_STRING} [L]
RewriteRule ^.*[-/]v(\d+)[-/]b(\d+)[-/].*$ index\.php?id=$1-$2&%{QUERY_STRING} [L]
# http://www.rackspace.com/knowledge_center/frequently-asked-question/why-is-mod-rewrite-not-working-on-my-site
Options +FollowSymlinks
# Options +SymLinksIfOwnerMatch
RewriteEngine On
RewriteBase /
# ------------------------------------------------------------------------------
# | Suppressing / Forcing 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. This can cause SEO problems
# (duplicate content), therefore, you should choose one of the alternatives and
# redirect the other one.
# By default option 1 (no "www.") is activated:
# http://no-www.org/faq.php?q=class_b
# If you'd prefer to use option 2, just comment out all the lines from option 1
# and uncomment the ones from option 2.
# IMPORTANT: NEVER USE BOTH RULES AT THE SAME TIME!
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Option 1: rewrite www.example.com → example.com
#
# RewriteCond %{HTTPS} !=on
# RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
# RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Option 2: rewrite example.com → www.example.com
# Be aware that the following might not be a good idea if you use "real"
# subdomains for certain parts of your website.
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
RewriteCond %{HTTP_HOST} !=localhost [NC]
RewriteCond %{HTTP_HOST} !=127.0.0.1
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]