0

My webpage on the university domain was located at:

www.example.edu/~myusername

I only have the index.html inside my public_html directory in my home area on the linux server.

I want to redirect homepage (which is the only page I have) to a new domain

www.example.com

I have tried to redirect the old index.html to the new index.html using 301 redirect and the standard methods found online using the .htaccess file, but it doesn't seem to work.

  • 1
    Well, this kind of thing is really basic for most anyone to do. Not saying you did not have a problem, but without knowing what exactly you did to attempt this action, how can we help? Can you provide us with an example of what you placed in your HTML file? – JakeGould Jan 6 '18 at 2:45
1

If your university webserver uses Apache httpd, the most robust method is to place a .htaccess file within the document root:

Redirect 301 / https://www.example.com/

This will also redirect subpaths correctly.


Failing that, the second-best way is to use a scripting language (if you have access to one) to send a redierct header. This can be a PHP script, or a CGI script (placed in cgi-bin).


If all else fails, you can place a meta refresh within your HTML file. This is the worst method, as it requires the browser to load the HTML page and then load the page it redirects to, while the redirect headers don't require loading the body. A meta refresh cannot be used to send a 301 redirect (which is necessarily an HTTP header).

  • Just to clarify - this is the folder structure that I have /home/myusername/public_html And my website address is www.univ.edu/~myusername. I placed a .htaccess file inside the aforementioned public_html folder with the following content. RewriteEngine On Options +FollowSymLinks Redirect 301 / https://www.example.com/ However, I get a 500 internal server error when I do this. – nilc Jan 6 '18 at 17:57
  • You should not need RewriteEngine as Redirect is provided by mod_alias. Also try playing with paths like redirecting from /~username/. And try quoting the paths. – Bob Jan 7 '18 at 1:02
  • Thank you @Bob. Turns out removing the first two lines and simply putting Redirect 301 /~username http://www.example.com worked. – nilc Jan 7 '18 at 9:34

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.