Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save abhinav4848/63c5be26285a595dbc1257419dbbdd72 to your computer and use it in GitHub Desktop.
Save abhinav4848/63c5be26285a595dbc1257419dbbdd72 to your computer and use it in GitHub Desktop.

Say you have http://abhinav.spsdarj.org/2017/12/how-to-redirect-base-url-addresses-to-another-base-url/ as a url on your old website (abhinav.spsdarj.org) and now you want the link to redirect to new website. Say abhinavkr.ga but the url following abhinavkr.ga should stay the same and when typing the old url, should magically redirect with rest of the link intact to the new website.

Here’s what you do. Go to the old site’s folder in your file manager, access the .htaccess and add this:

RewriteEngine on

RewriteCond %{HTTP_HOST} ^abhinav\.spsdarj\.org$ [OR]
RewriteCond %{HTTP_HOST} ^www\.abhinav\.spsdarj\.org$
RewriteRule ^(.*)$ "http\:\/\/blog\.abhinav\.ga\/$1" [R=301,L]

This supports multiple redirects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment