Skip to content

Instantly share code, notes, and snippets.

@metelkin
Last active September 23, 2018 10:09
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 metelkin/ff5e0cb6ca11b438a7885f522834016a to your computer and use it in GitHub Desktop.
Save metelkin/ff5e0cb6ca11b438a7885f522834016a to your computer and use it in GitHub Desktop.
Examples of redirecting on apache server
### sudo a2ensite redirect.apache2.conf
### sudo service apache2 restart
### target may be http or https
### Permanent redirect user browser to http://target.example.com
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName source.example.com
ServerAlias source2.example.com
Redirect permanent "/" "http://target.example.com"
</VirtualHost>
### Temporal redirect user browser to http://target.example.com
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName source.example.com
ServerAlias source2.example.com
Redirect "/" "http://target.example.com"
</VirtualHost>
### redirect user browser to path
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName source.example.com
ServerAlias source2.example.com
RedirectMatch ^ "http://target.example.com/another/path"
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment