Personal domain

Can I get my own web hostname?


All CSE accounts get an automatic virtual hostname on our web servers:

For example, is equivalent to

It runs on the CGI servers, so you can put PHP and other CGI Scripts there.

To be clear, this isn't a full virtualhost - you can't run an appserver this way, for instance - but it does give you prettier URLs for hosted content.

Redirecting web requests

If you want, you can automatically redirect visitors from to

To do this, you need to create or edit your .htaccess file.

Because of the way these hostnames are implemented, you can't just use the Redirect directive to do this, or you'll get a redirection loop.

Instead, you'll need to use the Apache RewriteEngine.

Create or edit ~/public_html/.htaccess, which controls your top-level directory.

Add this to the top of the file, replacing <username> with your username:

RewriteEngine On RewriteCond %{HTTP_HOST} !^<username> [NC] RewriteRule (.*) http://<username>$1 [R=301,L]

Important Notes

  • If you're POST forms, then you will need to make sure that the form uses the right domain name - POST data is lost on redirect
  • If you're using HTTPS, you need to change http to https in the snippet above.

How does it work?

See the mod rewrite docs - but put simply, the rule says: "if the hostname isn't, then redirect the browser to that hostname."

See Also

Last edited by jbc 08/04/2020

Tags for this page:

domain, web, htaccess