Skip to content

Instantly share code, notes, and snippets.

@Shumaher
Last active February 1, 2020 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shumaher/a4b8a064a023e56afea9bc359223e48d to your computer and use it in GitHub Desktop.
Save Shumaher/a4b8a064a023e56afea9bc359223e48d to your computer and use it in GitHub Desktop.
mod_rewrite redirects for SEO, see http://blog.alexz.me/seo-redirects for more info
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# https:
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R=301,L]
# /? to /
RewriteCond %{THE_REQUEST} ^[^\s]+\s+[^?]*?\?
RewriteCond %{QUERY_STRING} =""
RewriteRule .? %{REQUEST_URI}? [R=301,L]
# index* to /
RewriteRule ^index((\.html?)|/?)?$ / [NC,R=301,L]
# home* to /
RewriteRule ^home((\.html?)/?|(\.php)/?)?$ / [NC,R=301,L]
# * to /
RewriteRule ^.*\*.*$ / [NC,R=301,L]
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment