• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Domain forwarding with htaccess

coolemail2

Basic Pleskian
I have re-built a website on a new domain. Now I want to redirect http://www.olddomain.com/anything or http://olddomain.anything to www.newdomain. Because the file structure is totally different, I want all redirections to go to the Home Page of newdomain.

Initially, I used Standard forwarding in the Plesk CP but that attempts to keep the filename the same. So www.olddomain.com/wibble tries to go to www.newdomain.com/wibble. But wibble dies not exist on the new domain.

Should I use htaccess with physical hosting instead on olddomain.com? Is the following correct?:

Code:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^olddomain.com [NC]
RewriteRule ^(.*)$ http://www.newdomain.com [R=301,L]

Will that basically cover any request? Anything that people have saved or which appears in Google searches, no matter whether http:// or http://www.

And for neatness on the new domain, I would like to add www to any request like http://newdomain.com/whatever to go to http://www.newdomain.com/whatever which I think means that Google analytics will report more accurately.

So would my htaccess file on newdomain.com be like this?:

Code:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^newdomain.com [NC]
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,L]

Many thanks, in advance for any help.
 
.htaccess on newdomain not working

In newdomaon.co.uk I have created a .htaccess file and put the following:

Code:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^newdomain.co.uk [NC]
RewriteRule ^(.*)$ http://www.newdomain.co.uk/$1 [R=301,L]

and when I go to http://domain.com it does not resolve to anything and I get told "This page can't be displayed. Make sure the web address http://newdomain.co.uk is correct."

What have I done wrong there? And I'd still welcome the advice on what do do for the olddomain redirection please.
 
I am delighted to say that for an olddomain.co.uk where we want to forward EVERYTHING to the Home Page of newdomain.co.uk, the following worked:

1. Change it from a standard forwarding account to a physical hosting account
2. Create a .htaccess file with the following in that file:
Code:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^olddomain.co.uk [NC]
RewriteRule ^(.*)$ http://www.newdomain.co.uk [R=301,L]

Now, if anyone can help me identify how to add www to any non-www request, I would be most grateful. This is what I am using to try and achieve redirecting http://mydomain.co.uk/ to http://www.mydomain.co.uk/. It should also work if an individual file is requested, such as http://mydomain.co.uk/file.html

Code:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mydomain.co.uk [NC]
RewriteRule ^(.*)$ http://www.mydomain.co.uk/$1 (L)

but what I get is:
HTML:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator to inform of the time the error occurred and of anything you might have done that may have caused the error.
More information about this error may be available in the server error log.

In the error log I am getting:
[Mon Jun 16 17:06:38 2014] [alert] [client 109.224.207.33] /var/www/vhosts/mydomain.co.uk/httpdocs/.htaccess: RewriteRule: bad flag delimiters

I do hope someone can help with that.
 
Back
Top