Permanent Redirects using .htaccess

Web hosting, FTP/database access, mirror services and hosted blogs
Post Reply
jate
Posts: 11
Joined: Sun Oct 02, 2005 10:27 pm

Permanent Redirects using .htaccess

Post by jate » Tue Sep 25, 2012 11:49 pm

Hi,

I was previously playing around and creating some fun websites using exetel's free webspace.
Since then I have now obtained a paid webhost but would like to set up a permanent redirect to the new address if anyone tries to access any one of the pages on the existing folder.

All the articles I've read on the internet have pointed me to create a .htaccess file.
I have done that, but it seems takes no effect at all.

So far I have something as such in my .htaccess
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]

Missing anything?


When accessing old site I get this:
Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, hosting@exetel.com.au and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Apache Server at home.exetel.com.au Port 80

Dazzled
Volunteer Site Admin
Posts: 6003
Joined: Mon Nov 13, 2006 1:16 pm
Location: Sydney

Re: Permanent Redirects using .htaccess

Post by Dazzled » Wed Sep 26, 2012 6:50 am

SysAdmin has previously advised that Options +FollowSymLinks is not enabled on the free server's Apache. Its usage has security implications.

jate
Posts: 11
Joined: Sun Oct 02, 2005 10:27 pm

Re: Permanent Redirects using .htaccess

Post by jate » Wed Sep 26, 2012 8:32 am

:(

Would you know a good way to perform this redirect if .htaccess is not a possible option?

Dazzled
Volunteer Site Admin
Posts: 6003
Joined: Mon Nov 13, 2006 1:16 pm
Location: Sydney

Re: Permanent Redirects using .htaccess

Post by Dazzled » Wed Sep 26, 2012 11:06 am

You want a browser pointed at the site to get a 301 or 302 redirection. Try letting a server PHP script do the job for you. You shouldn't let Apache see any HTML beforehand, so remove any index.html file, and use index.php like this:
<?
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.exetel.com.au/", TRUE, 301 );
exit;
?>


302 redirects are similar. The manual and comments are at http://us3.php.net/manual/en/function.header.php
It won't work if users go straight to an unchanged subdirectory.

Post Reply