Skip to content

Instantly share code, notes, and snippets.

@randyjhunt
Created January 5, 2009 08:09
Show Gist options
  • Save randyjhunt/43326 to your computer and use it in GitHub Desktop.
Save randyjhunt/43326 to your computer and use it in GitHub Desktop.
Apache permanent redirect
# configure RedirectPermanent in Apache vhost
# step 1: new virtual hosts for each domain
# step 2: RedirectPermanent in each new vhost file
RedirectPermanent / http://mysite.org
# put the RedirectPermanent inside a vhost for each mysite.com and mysite.net
# RedirectPermanent is part of mod_alias
# this was done so multiple domain extensions would all change to the same extension
# rather than render the same site while maintaining different extensions
####################
# Example
####################
located in /etc/apache2/sites-available/mysite.net
####################
# Place any notes or comments you have here
# It will make any customisation easier to understand in the weeks to come
# domain: mysite.net
# public: /home/user/public_html/mysite.net/
<VirtualHost *:80>
# Admin email, Server Name (domain name) and any aliases
ServerAdmin webmaster@mysite.net
ServerName mysite.net
ServerAlias www.mysite.net
RedirectPermanent / http://mysite.com
# Index file and Document Root (where the public files are located)
DirectoryIndex index.html
DocumentRoot /home/user/public_html/mysite.net/public
# Custom log file locations
LogLevel warn
ErrorLog /home/user/public_html/mysite.net/log/error.log
CustomLog /home/user/public_html/mysite..net/log/access.log combined
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment