Skip to content

Instantly share code, notes, and snippets.

@nikola-wd
Created July 3, 2019 00:48
Show Gist options
  • Save nikola-wd/d7265dc92bb8225a5e1af2b460a6e291 to your computer and use it in GitHub Desktop.
Save nikola-wd/d7265dc92bb8225a5e1af2b460a6e291 to your computer and use it in GitHub Desktop.
mwe .htaccess example
# ----------------------------------------------------------------------
# Rewrites / permalinks
# ----------------------------------------------------------------------
# ----------------------
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
# END WordPress
# ----------------------
# ----------------------------------------------------------------------
# WordPress security
# ----------------------------------------------------------------------
# protect the htaccess file
<files .htaccess>
order allow,deny
deny from all
</files>
# protect wpconfig.php
<files wp-config.php>
order allow,deny
deny from all
</files>
# ----------------------------------------------------------------------
# 301 redirects
# ----------------------------------------------------------------------
# redirect 301 /this/page http://www.mixd.co.uk/to/here
# RedirectMatch 301 ^/containing.*$ http://www.mixd.co.uk/to/here
RedirectMatch 301 ^/blog/emr-interface/?$ /
RedirectMatch 301 ^/blog/emr-patient-portals/?$ /
Redirect 301 /blog/2011/09/21/good-bye-flash-what-the-new-ie-10-means-for-your-legal-website-design /
Redirect 301 /blog/3-ways-84000-followers-firms-facebook-page /
Redirect 301 /blog/5-tips-for-a-successful-press-release /
Redirect 301 /blog/7-ways-promote-legal-blog /
Redirect 301 /blog/article-title-secrets-7-ways-to-attract-more-readers /
Redirect 301 /blog/attorney-social-bookmarking-site-launched-legal-web-experts /
Redirect 301 /blog/crees-que-eres-gracioso-5-tips-para-usar-el-humor-en-su-campana-de-marketing /
Redirect 301 /blog/el-poder-del-contenido-en-marketing-339 /
Redirect 301 /blog/faq-how-does-search-engine-work-11-323 /
Redirect 301 /blog/four-reasons-you-cant-i /
Redirect 301 /blog/future-social-media-law-firms /social-media
Redirect 301 /blog/glossary /
Redirect 301 /blog/good-bye-flash-what-the-new-ie-10-means-for-your-legal-website-design /
Redirect 301 /blog/happy-halloween-from-new-wave-web-and-marketing /
Redirect 301 /blog/happy-holidays-legal-web-experts-12-323 /
Redirect 301 /blog/happy-holidays-legal-web-experts-12-323/attorney-blog.php /
Redirect 301 /blog/happy-holidays-legal-web-experts-12-323/latino-legal-marketing.php /
Redirect 301 /blog/happy-holidays-legal-web-experts-12-323/legal-web-design.php /
Redirect 301 /blog/happy-holidays-legal-web-experts-12-323/mobile-website-design.php /
Redirect 301 /blog/healthcare-web-design/contact-us.php /
Redirect 301 /blog/how-to-best-market-your-business-online-11-323 /
Redirect 301 /blog/how-to-get-the-most-out-of-a-press-release-1012-323 /
Redirect 301 /blog/how-to-use-google-analytics-to-attract-quality-website-traffic /
Redirect 301 /blog/how-to-work-your-html-anchor-text-links-for-better-seo /
Redirect 301 /blog/ideas-for-increasing-your-of-likes-on-facebook-2 /
Redirect 301 /blog/increase-press-release-reach-1012-323 /
Redirect 301 /blog/is-keyword-density-dead-the-new-way-google-is-scanning-your-site-for-keywords /
Redirect 301 /blog/las-empresas-deben-utilizar-marketing-en-linea-hoy-en-dia-339 /
Redirect 301 /blog/law-firm-investment-2012 /
Redirect 301 /blog/legal-marketing-strategies-11-323 /
Redirect 301 /blog/legal-website-design-mobile-friendly /
Redirect 301 /blog/link-wheeling-part-ii-how-to-build-a-link-wheel /
Redirect 301 /blog/marketing-legal-business-11-323 /
Redirect 301 /blog/market-legal-business-online-113-323 /
Redirect 301 /blog/mobile-browsing-tablets-rise-32 /
Redirect 301 /blog/modern-legal-website-design-necessity-growing-firm /
Redirect 301 /blog/new-york-stands-up-for-same-sex-marriage-1012-323 /
Redirect 301 /blog/no-mining-on-flight-93-site-1012-323 /
Redirect 301 /blog/principales-tendencias-de-comercializacion-y-tecnicas-de-marketing-actuales /
Redirect 301 /blog/que-es-google-panda-parte-i /
Redirect 301 /blog/scanlan-law-group-new-website-live-1012-323 /
Redirect 301 /blog/search-engine-optimization-6-ways-to-turn-traffic-into-customers-323 /
Redirect 301 /blog/search-engine-work-11-323 /
Redirect 301 /blog/small-medium-size-law-firm-spend-marketing /
Redirect 301 /blog/tips-effective-call-to-action-113-323 /
Redirect 301 /blog/tips-humanizing-legal-brand-113-323 /
Redirect 301 /blog/tips-legal-web-design-tip-1 /
Redirect 301 /blog/tips-legal-web-design-tip-2-domain-concerns /
Redirect 301 /blog/tips-legal-web-design-tip-3-trademark-concerns /
Redirect 301 /blog/tips-legal-web-design-tip-4-defamation-concerns /
Redirect 301 /blog/tips-legal-web-design-tip-5-linking-concerns /
Redirect 301 /blog/top-5-translation-fails-in-advertising /
Redirect 301 /blog/top-6-de-las-clasicas-fallas-en-la-traduccion-publicitaria /
Redirect 301 /blog/top-7-legal-marketing-trends-techniques-11-323 /
Redirect 301 /blog/top-7-legal-marketing-trends-techniques-11-323/attorney-blog.php /
Redirect 301 /blog/top-7-legal-marketing-trends-techniques-11-323/latino-legal-marketing.php /
Redirect 301 /blog/top-7-legal-marketing-trends-techniques-11-323/legal-practice-marketing.php /
Redirect 301 /blog/top-7-legal-marketing-trends-techniques-11-323/legal-web-design.php /
Redirect 301 /blog/top-7-legal-marketing-trends-techniques-11-323/mobile-website-design.php /
Redirect 301 /blog/untold-advantages-working-small-law-firm /
Redirect 301 /blog/vlo-solution-reduced-usps-mail-services-attorney-web-design-firm /
Redirect 301 /blog/ways-search-engine-optimization-turn-traffic-clients-323 /
Redirect 301 /blog/why-market-your-business-online-113-323 /
Redirect 301 /blog/hill-country-apothecary /blog/
RedirectMatch 301 ^/blog/category/healtcare-website-development/?$ /blog/
RedirectMatch 301 ^/blog/por-que-implementar-portal-de-salud-para-pacientes/?$ /blog/
RedirectMatch 301 ^/blog/felices-fiestas-de-parte-de-medical-web-experts-339/?$ /blog/
RedirectMatch 301 ^/blog/que-es-el-seo-339/?$ /blog/
RedirectMatch 301 ^/blog/1128-339/?$ /blog/
RedirectMatch 301 ^/blog/1111-339/?$ /blog/
RedirectMatch 301 ^/blog/por-que-los-proveedores-de-salud-deberian-usar-marketing-con-contenido-en-linea-339/?$ /blog/
RedirectMatch 301 ^/blog/como-maximizar-el-alcance-de-comunicado-de-prensa-339/?$ /blog/
RedirectMatch 301 ^/blog/el-contenido-en-marketing-debe-cambiar-cuando-el-seo-cambia-339/?$ /blog/
RedirectMatch 301 ^/blog/principales-tendencias-de-comercializacion-tecnicas-de-marketing-actuales-339/?$ /blog/
RedirectMatch 301 ^/blog/como-funcionan-los-motores-de-busqueda-339/?$ /blog/
RedirectMatch 301 ^/blog/contenido-unico-resultados-relevantes-2/?$ /blog/
RedirectMatch 301 ^/blog/la-mirada-del-cliente-frente-al-diseno-2/?$ /blog/
RedirectMatch 301 ^/blog/the-mhealth-app-scorecard-scoring-21-healthcare-mobile-apps-from-americas-top-hospitals-and-health-systems/?$ /blog/
Redirect 301 /blog/5-mistakes-you-will-make-in-your-internet-marketing-campaign /
Redirect 301 /blog/como-publicar-un-articulo-en-su-blog-de-wordpresss-un-tutorial-seo-paso-por-paso /
Redirect 301 /blog/companies-should-engage-in-online-content-marketing-1012-323 /
Redirect 301 /blog/cuando-el-seo-cambia-el-contenido-de-marketing-tambien-debe-hacerlo /
Redirect 301 /blog/emr-patient-portals/aboutus.php /
Redirect 301 /blog/four-important-html-meta-tags-for-seo /
Redirect 301 /blog/google-acquires-social-media-startup-wildfire /
Redirect 301 /blog/growing-number-small-businesses-attract-clients-social-media-stronger-online-presence-628 /
Redirect 301 /blog/happy-holidays-legal-web-experts-12-323/videoproduction.php /
Redirect 301 /blog/healthcare-web-design-instantly-convey-patients/hospitals.php /
Redirect 301 /blog/is-seo-spam-google-officially-says-no /
Redirect 301 /blog/learn-seo-bascis-from-wikipedia-1012-323 /
Redirect 301 /blog/legal-businesses-invest-online-content-marketing-1012-32 /
Redirect 301 /blog/leverage-legal-website-design-seo /
Redirect 301 /blog/link-building-strategy-for-google-seo-success /
Redirect 301 /blog/local-seo-strategies-that-can-attract-customers-to-your-business-628 /
Redirect 301 /blog/optimizing-social-media-legal-marketing-strategies /
Redirect 301 /blog/power-brands-content-marketing-1012-323 /
Redirect 301 /blog/ppc-advertising-101-basics-google-bing-facebook /
Redirect 301 /blog/security/website-security-medical-practices /
Redirect 301 /blog/seven-fun-facts-about-social-media /
Redirect 301 /blog/siete-datos-curiosos-acerca-de-los-medios-de-comunicacion-social /
Redirect 301 /blog/social-essential-succeed-323 /
Redirect 301 /blog/specialties/health-and-wellness/health-it/emr-patient-portals /
Redirect 301 /blog/study-shows-having-a-social-media-profile-can-make-followers-more-likely-to-buy-your-product /
Redirect 301 /blog/the-branding-power-of-content-marketing-1012-323 /
Redirect 301 /blog/the-seo-benefits-of-an-online-newsletter /
Redirect 301 /blog/top-7-legal-marketing-trends-techniques-11-323/law-firm-seo.php /
Redirect 301 /blog/video-convert-legal-website-design /
Redirect 301 /blog/ways-draw-people-business-local-seo-strategies-628 /
Redirect 301 /blog/what-are-anchor-text-links-and-why-are-they-important-for-seo /
Redirect 301 /blog/what-is-black-hat-seo /
Redirect 301 /blog/what-is-html-part-two-seo-benefit-and-sample-code /
Redirect 301 /blog/why-social-media-can-be-a-bad /
Redirect 301 /blog/why-social-media-can-be-a-bad-investment-for-physicians /
Redirect 301 /blog/health-it/emr-interface /
Redirect 301 /blog/health-it/emr-patient-portals /
Redirect 301 /blog/medical-website-design/doctor-web-design /
Redirect 301 /blog/medical-website-design/mobile-website-design /
Redirect 301 /blog/seo-search-engine-optimization /
Redirect 301 /blog/ppc-pay-per-click-advertising /
Redirect 301 /blog/medical-digital-marketing/content-writing /
# ----------------------------------------------------------------------
# Gzip compression
# ----------------------------------------------------------------------
<IfModule mod_deflate.c>
# Force deflate for mangled headers developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
</IfModule>
</IfModule>
# Compress all output labeled with one of the following MIME-types
<IfModule mod_filter.c>
AddOutputFilterByType DEFLATE application/atom+xml \
application/javascript \
application/json \
application/rss+xml \
application/vnd.ms-fontobject \
application/x-font-ttf \
application/xhtml+xml \
application/xml \
font/opentype \
image/svg+xml \
image/x-icon \
text/css \
text/html \
text/plain \
text/x-component \
text/xml
</IfModule>
</IfModule>
# ----------------------------------------------------------------------
# Expires headers (for better cache control)
# ----------------------------------------------------------------------
# These are pretty far-future expires headers.
# They assume you control versioning with filename-based cache busting
# Additionally, consider that outdated proxies may miscache
# www.stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring/
# If you don't use filenames to version, lower the CSS and JS to something like
# "access plus 1 week".
<IfModule mod_expires.c>
ExpiresActive on
# Perhaps better to whitelist expires rules? Perhaps.
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"
# Your document html
ExpiresByType text/html "access plus 0 seconds"
# Data
ExpiresByType text/xml "access plus 0 seconds"
ExpiresByType application/xml "access plus 0 seconds"
ExpiresByType application/json "access plus 0 seconds"
# Feed
ExpiresByType application/rss+xml "access plus 1 hour"
ExpiresByType application/atom+xml "access plus 1 hour"
# Favicon (cannot be renamed)
ExpiresByType image/x-icon "access plus 1 week"
# Media: images, video, audio
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType video/ogg "access plus 1 month"
ExpiresByType audio/ogg "access plus 1 month"
ExpiresByType video/mp4 "access plus 1 month"
ExpiresByType video/webm "access plus 1 month"
# HTC files (css3pie)
ExpiresByType text/x-component "access plus 1 month"
# Webfonts
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 and JavaScript
ExpiresByType text/css "access plus 1 week"
ExpiresByType application/javascript "access plus 1 week"
</IfModule>
# ----------------------------------------------------------------------
# Better website experience for IE users
# ----------------------------------------------------------------------
# Force the latest IE version, in various cases when it may fall back to IE7 mode
# github.com/rails/rails/commit/123eb25#commitcomment-118920
# Use ChromeFrame if it's installed for a better experience for the poor IE folk
<IfModule mod_headers.c>
Header set X-UA-Compatible "IE=Edge,chrome=1"
# mod_headers can't match by content-type, but we don't want to send this header on *everything*...
<FilesMatch "\.(js|css|gif|png|jpe?g|pdf|xml|oga|ogg|m4a|ogv|mp4|m4v|webm|svg|svgz|eot|ttf|otf|woff|ico|webp|appcache|manifest|htc|crx|oex|xpi|safariextz|vcf)$" >
Header unset X-UA-Compatible
</FilesMatch>
</IfModule>
# ----------------------------------------------------------------------
# Webfont access
# ----------------------------------------------------------------------
# Allow access from all domains for webfonts.
# Alternatively you could only whitelist your
# subdomains like "subdomain.example.com".
<IfModule mod_headers.c>
<FilesMatch "\.(ttf|ttc|otf|eot|woff|font.css)$">
Header set Access-Control-Allow-Origin "*"
</FilesMatch>
</IfModule>
# ----------------------------------------------------------------------
# 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 .atom .css .js .json .rss .vtt .xml
# ----------------------------------------------------------------------
# Proper MIME type for all files
# ----------------------------------------------------------------------
# JavaScript
AddType application/javascript js jsonp
AddType application/json json
# Audio
AddType audio/ogg oga ogg
AddType audio/mp4 m4a f4a f4b
# Video
AddType video/ogg ogv
AddType video/mp4 mp4 m4v f4v f4p
AddType video/webm webm
AddType video/x-flv flv
# SVG
AddType image/svg+xml svg svgz
AddEncoding gzip svgz
# Webfonts
AddType application/vnd.ms-fontobject eot
AddType application/x-font-ttf ttf ttc
AddType font/opentype otf
AddType application/x-font-woff woff
# Assorted types
AddType image/x-icon ico
AddType image/webp webp
AddType text/cache-manifest appcache manifest
AddType text/x-component htc
AddType application/xml rss atom xml rdf
AddType application/x-chrome-extension crx
AddType application/x-opera-extension oex
AddType application/x-xpinstall xpi
AddType application/octet-stream safariextz
AddType application/x-web-app-manifest+json webapp
AddType text/x-vcard vcf
AddType application/x-shockwave-flash swf
AddType text/vtt vtt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment