htaccess redirect duplicate content from hosting company - .htaccess

Please help me to avoid duplicate content of my site
I have a web site, let say www.example.com.
My hosting company (netfirms) also provide address for our web site using their domain, which is example.netfirms.com
How to redirect all links to example.netfirms.com to www.example.com ??
please provide SEO friendly solution
regards
eddy ajis

Try this:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^OLDDOMAIN\.com$ [NC]
RewriteRule ^(.*)$ http://NEWDOMAIN.com [R=301,L]

Related

Redirect from old subdomain/domain to new domain using htaccess

My website was on a subdomain, like this: mysite.primarydomain.com. The primarydomain.com DNS was managed by a third party who owns the primarydomain.com url.
My new website is now on on mysite.com. I had the third party add an a record that points mysite.primarydomain.com to my new website's IP address. How can I then redirect that mysite.primarydomain.com domain to mysite.com? Would that be via htaccess? Or via cpanel configuration?
Thanks!
There's probably a cpanel configuration to do this pretty easily, probably something like this: http://docs.cpanel.net/twiki/bin/view/AllDocumentation/WHMDocs/SetupForwarding
But you can also add an htaccess file to the document root of the mysite.primarydomain.com site, that says:
Redirect 301 / http://mysite1.com/
or if the document root is shared, you'll need:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mysite\primarydomain\.com$ [NC]
RewriteRule ^(.*)$ http://mysite1.com/$1 [L,R=301]
Thanks Jon Lin for your answer. It inspired me to find a very easy method in cpanel...
In the primarydomain.com, I created a subdomain for "mysite.primarydomain.com".
I then went to "Redirects". Since I added the "mysite." subdomain, it gave me the option to create a redirect using that subdomain. So I created a redirect for mysite.primarydomain.com to point to mysite.com.
I then was able to create a few other redirects to help keep some of their old links live, such as "mysite.primarydomain.com/about".
Thanks!
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^subdomain.domain\.com$ [NC]
RewriteRule ^(.*)$ http://newdomain.com/$1 [R=301,L]

Redirect www.example.com to example.com

I've a domain hosted on bluehost with iLister CMS installed in, the problem which I'm facing is http://www.advett.com/admin isn't responding because I registered advett.com/admin in the site_url field of iLister license.
How to redirect all the request for www.advett.com and www.advett.com/admin to advett.com and advett.com/admin respectively?
I know it can be done with .htaccess but I've not been able to find a solution till now.
Try putting this in the htaccess file in your document root:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.advett\.com [NC]
RewriteRule ^(.*)$ http://advett.com/$1 [L,R=301]

htaccess redirect subdomain to $_GET

Need some help with htaccess
For a sort of image storage site i need this:"
if users come to http:// subdomain.mysite.com/#RANDOMSTRING/ the server has to act like if it is the url: http:// subdomain.mysite.com/index.php?image=#RANDOMSTRING, but the visitor doesnt have to see this.
Also, on www. mysite.com (so not in the subdomain) there is a wordpress with htaccess for seo friendly urls. (Don't know if this has something to do with it, but because i need to upload files for http:// subdomain.mysite.com to ftp:// www.mysite.com/subdomain)
Hope to hear from you, thank you!
In the htaccess file in the subdomain.mysite.com document root add:
RewriteEngine On
RewriteRule index\.php - [L]
RewriteCond %{HTTP_HOST} ^subdomain.mysite.com$ [NC]
RewriteRule ^(.+?)/?$ /index.php?image=$1 [L]
You may not need the RewriteCond at all because it seems your 2 domains (subdomain and www) are in different document roots.

.htaccess to redirect homepage to "about" page for desktop users

On a wordpress website, we're using wptouch pro plugin to provide a mobile version of the website (so no separate mobile website).
We get mobile traffic through a QR code pointing to our frontpage (e.g. www.example.net). However, we'd like desktop users to be redirected to www.example.net/about/ page.
Is it possible to do this through the use of .htaccess or another way would be better?
For example, adding :
RewriteEngine On
RewriteRule ^$ /about/ [R=301,L]
before Wordpress .htaccess data
redirects all traffic from www.example.net to www.example.net/about/
Is it possible to put a condition that this redirect should only visitor is not within specified (mobile) user agents?
Thanks a lot in advance!
Something like this should work:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_USER_AGENT} ^.*(MSIE.*Windows\ NT|Lynx|Safari|Opera|Firefox|Konqueror) [NC]
RewriteRule ^$ about/ [L,R]

Can you do a redirect in .htaccess, and preserve the URI?

Is there a way to use .htaccess to redirect example.net to example.com, so that the URI example.net stays the same in the client's browser?
I found these examples from this link:
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} domain2.com
RewriteCond %{REQUEST_URI} !subdirectory/
RewriteRule ^(.*)$ subdirectory/$1 [L]
or
RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} domain2.com
RewriteCond %{REQUEST_URI} !mychatfolder/
RewriteRule ^(.*)$ http://www.domain1.com/subfolder/$1 [L]
I haven't tested these out though.
If I'm understanding your question correctly, what you want is two sites which appear exactly the same, but neither one redirects to the other. You want the person who visits example.net to see the same stuff as is on example.com, but they should still see example.net in their browser address bar.
There are a few ways of doing this. The simplest, of course, is to simply upload the same content to both sites, but this might make updating tricky. Another is to set one domain as an alias of the other; exactly how to do this will depend on your server configuration. It would be simpler, and would perhaps be better for SEO purposes, to redirect one domain to the other.
RewriteEngine On
RewriteRule ^(.*)$ http://www.example.com/$1 [R=302,L]
# 302 is a temporary redirect. Use it for testing purposes. Once you're sure it works, change it to 301.
If you want the domain example.net to point to example.com then the best way isn't rewriting it, but to park that domain to example.com and the app. for that is basically titled as Parked Domains that's in Domains section if your control panel is cPanel or if your web hosting account features an app. that can park a domain.

Resources