Last active
October 24, 2018 07:11
-
-
Save cmg-jess/1c6c2fae54fe008a2245 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RewriteEngine On | |
#error 410 | |
ErrorDocument 410 default | |
#redirect home page to specific page without redirecting other urls | |
RewriteRule ^/?$ http://domain.com/folder/page/ [L,R] | |
#redirect www to non wwww | |
RewriteCond %{HTTP_HOST} ^www.domain.com [NC] | |
RewriteRule ^(.*) http://domain.com/$1 [L,R=301] | |
#redirect non www to wwww | |
RewriteCond %{HTTP_HOST} ^domain.com [NC] | |
RewriteRule ^(.*) http://www.domain.com/$1 [L,R=301] | |
#redirect all pages from old domain to new domain, maintaining URL structure | |
RewriteEngine On | |
RewriteCond %{HTTP_HOST} ^www\.domain1\.com$ | |
RewriteRule ^(.*)$ http://domain2.com/$1 [L,R=301] | |
Redirect 301 / http://domain2.com/ | |
#redirect specific query string to path | |
RewriteCond %{QUERY_STRING} p=259 | |
RewriteRule ^blog/$ http://domain.com/specific-page-nam/? [L,R=301] | |
#redirect all pages within a directory | |
RewriteRule ^parent1/parent2/(.*)$ / [R=301,NC,L] | |
#redirect file/path with spaces to new url | |
RewriteRule ^/pages/articles/folder/Name\ of\ file\ with\ spaces\ in\ it.pdf http://domain.com/new-file-name.pdf | |
#redirect URL with ? to specific page - no query | |
RewriteRule ^page/page2/page3/?$ http://domain.com/newpage/? [R=301,L] | |
#410 query string | |
RewriteCond %{QUERY_STRING} key=value | |
RewriteRule .* - [G,NC] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment