: Site-wide redirect with Tomcat4 Disclaimer: My webmastering experience is almost nil. Apologies if anything seems ignorant - if it sounds that way, it probably is. My employer is in the middle
Disclaimer: My webmastering experience is almost nil. Apologies if anything seems ignorant - if it sounds that way, it probably is.
My employer is in the middle of switching over from one version of their website to another, and for the time being would like for the old site to redirect to the new one, but have the pages of the old site preserved as a backup of sorts.
After some Google searches, I found that an easy way to perform a site-wide redirect is by adding the following line to a .htaccess file:
Redirect 301 / www.website.com
Prior to this task being given to me, the site did not have a .htaccess file, so I created one and it contains only that line. Once that file was saved, attempts to load the old site's URL yielded 500 Internal Server Error.
I am certain that I'm missing something which might be obvious to an experienced webmaster. What more do I need to do to make this redirect hold?
More posts by @Moriarity557
2 Comments
Sorted by latest first Latest Oldest Best
Despite this probably being a common requirement I can't find another question just like it, so here's what to put in your htaccess file. If you want to keep the part of the url after the slash (so olddomain.com/something redirects to newdomain.com/something) do this:
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) www.newdomain.com/ [R=301,L]
If you want the redirect to just take them to the home page then use this:
RewriteRule (.*) www.newdomain.com/ [R=301,L]
Redirect directive is part of mod_alias module. Make sure that you have this line (or similar) uncommented (no # in front) in your httpd.conf file:
LoadModule alias_module modules/mod_alias.so
Another possible reason: add trailing slash / if redirecting to the root folder:
Redirect 301 / www.website.com/
In any case -- you should check your Apache's error log for details.
UPDATE:
If you have full control over your server, make sure that you have AllowOverride All directive in your Apache config file (httpd.conf or httpd-vhost.conf), for example inside appropriate <VirtualHost>:
<Directory "/path/to/website/root">
AllowOverride All
</Directory>
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.