Apache rewrite

Here is how to make a redirct work, first add this A record to your database file on the DNS server that manages the the ServerAlias below. Don’t forget to update the serial # if you are old school and still manually edit your database files like me.

cool.computerking.ca IN A XXX.XXX.XXX.XXX

Next add the following to your virtual host within the apache.conf file as you can see i simplified a complex URL down to cool.computerking.ca.

ServerAlias cool.computerking.ca
RewriteEngine on
RewriteCond %{HTTP_HOST} =cool.computerking.ca
RewriteRule ^(.*) http://some.evencoolerplace.com:65000/ucanaddaliasestoo/ [R]

You can also do this with an .htaccess file below is a different example of just pointing the websever to a subdirectory within your public_html folder. Just add an .htaccess file to the websites root directory useally public_html. Thinking the .htaccess file is a bit of a hack ugly hack, but good if u do not have access to your cool.conf files poor you.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(cool.)?computerking.ca$
RewriteRule ^(/)?$ coolerdirctory [L]

Well, hello, Dolly

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.