Redirect cpanel temporary url to main site

elite

Registered
Apr 24, 2005
3
0
151
My site is getting indexed by search engines at both domain.com and hostname.com/~domain

Is there a way to set up a redirect so that anyone arriving at hostname.com/~domain will get a perminent redirect to domain.com?

Any help much appreciated!

Cheers

Nick
 

elite

Registered
Apr 24, 2005
3
0
151
Sorry, I probably wasn't clear.

While the domain propergated from the old host to the new I redirected the old server to hostname/~domain (the new server), now I want any requests on the new server that arrive at hostname/~domain to be redirected to domain.com.

I am mostly concerned about duplicate content for search engines as I'm now being indexed on both hostname/~domain and domain.com

Thanks for the response

cheers

Nick
 

MySitesOnline

Active Member
Mar 24, 2003
27
0
151
Sorry, I probably wasn't clear.

While the domain propergated from the old host to the new I redirected the old server to hostname/~domain (the new server), now I want any requests on the new server that arrive at hostname/~domain to be redirected to domain.com.

I am mostly concerned about duplicate content for search engines as I'm now being indexed on both hostname/~domain and domain.com

Thanks for the response

cheers

Nick
Hi,

Anyone have a solutions for this?
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
40
248
somewhere over the rainbow
cPanel Access Level
Root Administrator
The best solution is to not allow temporary urls anymore at all if everything has propagated. You should enable mod_userdir protection in WHM to disallow requests to that url, since you aren't gauging bandwidth if they come in at that url to that account. Bandwidth instead goes to the main server hostname and not the user's account.
 

netshine

Member
Dec 5, 2006
9
0
151
I want to allow the temporary URL domain.com/~username for most accounts, but just redirect from there to the live domain on a single website (so cPanelTristan's solution is not a good one for me). In case it helps anyone else, I found the following mod_rewrite redirect (in .htaccess) worked for me:

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI} /~username
RewriteRule (.*) http://www.example.com/$1 [R=301,L]