Zen Cart Logo
Forums / General Questions / website always redirect to ww6 or js

website always redirect to ww6 or js

Views: 3,337

Results 1 to 18 of 18
15 Aug 2013, 12:49 PM
#1
helpoftcm avatar

helpoftcm

New Zenner

Join Date:
Jul 2009
Posts:
7
Plugin Contributions:
0

website always redirect to ww6 or js

I have the following problem with my recently made Zen cart website.
It always redirects from https://www.mywebsite.com to ww6.mywebsite.com ww9.mywebsite.com or js.mywebsite.com
It happens mostly in the afternoon while in the morning I can have normal access.
I asked few friends from different countries, they can see the same.
My hosting company says it has nothing to do with them, their servers work properly.
I would very appreciate if someone knows what is the problem and how it can be fixed.

Thanks

15 Aug 2013, 1:04 PM
#2
picandnix avatar

picandnix

Totally Zenned

Join Date:
Dec 2010
Location:
UK
Posts:
1,780
Plugin Contributions:
2

Re: website always redirect to ww6 or js

click reply and answer the questions please.
also dies your site actually display when redirected?

15 Aug 2013, 1:49 PM
#3
helpoftcm avatar

helpoftcm

New Zenner

Join Date:
Jul 2009
Posts:
7
Plugin Contributions:
0

Re: website always redirect to ww6 or js

I can not open website now it redirects to http://ww6.ww9.ww9.ww9.ww9.nikogems.com/, must be nikogems dot com only. The actual website doesn't display.
I can not go to Cpanel or admin area too. I noticed the problem few days after the template was installed by the Chinese designer that I used to work with previously. He has no idea why it's happening like this. The website is not complete, there weren't payment modules installed yet.

15 Aug 2013, 2:24 PM
#4
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: website always redirect to ww6 or js

helpoftcm:

It always redirects from www.mywebsite.com to ww6.mywebsite.com ww9.mywebsite.com or js.mywebsite.com

I can understand and appreciate how the site could be redirected to one or the other of these URL, but your wording makes it appear that the exact site being redirected to is inconsistent, and that doesn't sit right with me. I am accustomed to software that has a predicable behaviour, namely, every peice of code I've ever come across.

I suspect that there is almost certainly going to be a pattern or sequence of events that causes it to redirect to one or the other, and it may prove beneficial to see if you can identify what the pattern is.

helpoftcm:

It happens mostly in the afternoon while in the morning I can have normal access.

This is a bit of a red herring. It has no meaning in this context. It is always 'afternoon' somewhere in the world, and it is quite possible that your 'afternoon' is actually 'midnight' where your server is located.

helpoftcm:

I asked few friends from different countries, they can see the same.

Not important, but did these friends visit your site during their afternoons, or did they test in the middle of the night when it was your afternoon? (Just trying to emphasize that 'mostly in the afternoon' hold no meaning without some fixed point of reference).
As I said though, I beleive this to be a red herring that has no bearing on the issue.

helpoftcm:

My hosting company says it has nothing to do with them, their servers work properly.

I've no idea who your hosting company is, but without knowing anything more about this problem I would be inclined to agree with them. It isn't a server fault.

helpoftcm:

I would very appreciate if someone knows what is the problem and how it can be fixed.

The problem is quite clear. You either have some erroneous redirection rules going on, OR, these 'redirected URL's' aren't what they appear, and are in fact a result of the URL's being hard coded somewhere.

It is generally an easy problem to resolve too.
Step#1 Look for a .htaccess file in the root folder of your store. If you find one, either rename or delete it.
Step#2. It the problem persists after performing step#1, use the Developers Toolkit and look for any hard coded links to the erroneous URL's
Step#3. If the problem still persists go back to step#1 and start again :)

Cheers
Rod

17 Aug 2013, 6:34 AM
#5
helpoftcm avatar

helpoftcm

New Zenner

Join Date:
Jul 2009
Posts:
7
Plugin Contributions:
0

Re: website always redirect to ww6 or js

Thank you for the explanations.
I would like to ask some expert to help me to solve this problem if possible as I am not a programmer .
Anyone can suggest where I can find the guy who could fix it?

Thanks

17 Aug 2013, 8:35 AM
#6
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: website always redirect to ww6 or js

helpoftcm:

I would like to ask some expert to help me to solve this problem if possible as I am not a programmer .

Before considering this, you don't need to be a programmer to
"Look for a .htaccess file in the root folder of your store. If you find one, either rename or delete it."

If I were a gambling man, I'd offer 1000/1 odds that this will solve your immediate problem.

<general comment, not specifically to helpoftcm>
Although I have no desire to offend anyone, but in my opinion, anyone that has a problem doing this shouldn't be trying to run their own store in the 1st place. Such people either need to learn the basics, or already have a developer lined up to solve this type of problem. Again, I don't mean to offend anyone by this. It is no different than saying a person shouldn't try to drive a car without learning how to put fuel in the tank.
Yes, I know some people have been driving for years and have never had to do this 'cos their partner does it for them when needed, but this akin to having a developer on hand, so the comparison remains valid).
</general comment>

To helpoftcm.
I/we don't expect you (or anyone) to become an expert programmer in order to run an online store, but we do kinda expect people to be able to follow instructions, else one starts to wonder how they'll ever manage to apply any security patches when needed, or how to recover from a hack, and even how to add or remove any of the addon modules. If you think I'm just trying to give you a hard time here, perhaps I am (its not personal), at the end of the day my attempts to push you into doing/trying things for yourself is for your benefit (and the protection of your customers), if this wasn't the case I'd have no problems in taking 'money for jam' from you. It would probably even take me less time (and effort) than my attempts to show you how to do it for yourself :)

Cheers
Rod

ps. Before trying anything, please make sure that you have a full back of the entire site. If you have a backup you'll probably never need to use it. If you don't have one, Murphey's Law dictates that you will need it. :)

17 Aug 2013, 12:39 PM
#7
helpoftcm avatar

helpoftcm

New Zenner

Join Date:
Jul 2009
Posts:
7
Plugin Contributions:
0

Re: website always redirect to ww6 or js

Thank you for the such a powerful explanation.
I am that kind of person who would rather pay and solve the problem quick than trying to find a solution by myself in forums especially when changing the code.

For the website, I found .htaccess file and I removed it, but that didn't help, there is still redirection and can not see the website.

17 Aug 2013, 1:13 PM
#8
picandnix avatar

picandnix

Totally Zenned

Join Date:
Dec 2010
Location:
UK
Posts:
1,780
Plugin Contributions:
2

Re: website always redirect to ww6 or js

helpoftcm:

Thank you for the such a powerful explanation.
I am that kind of person who would rather pay and solve the problem quick than trying to find a solution by myself in forums especially when changing the code.

For the website, I found .htaccess file and I removed it, but that didn't help, there is still redirection and can not see the website.

What was the content of your .htaccess file? remove any mention of your admin folder name before posting it though ok*

17 Aug 2013, 2:05 PM
#9
helpoftcm avatar

helpoftcm

New Zenner

Join Date:
Jul 2009
Posts:
7
Plugin Contributions:
0

Re: website always redirect to ww6 or js

NOTE: Replace /shop/ with the relative web path of your catalog in the "Rewrite Base" line below:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /

From Ultimate SEO URLs

RewriteRule ^(.)-c-([^/])/(.)-p-(.).html$ index.php?main_page=product_info&products_id=$4&cpath=$2 [L]
RewriteRule ^(.
)-p-(.*).html$ index.php?main_page=product_info&products_id=$2&%{QUERY_STRING} [L]

Normal Ultimate SEO URLs (disable if using ADD_PRODUCT_CAT)

#RewriteRule ^(.)-c-(.).html$ index.php?main_page=index&cPath=$2&%{QUERY_STRING} [L]

ADD_PRODUCT_CAT Ultimate SEO URLs (disable if not using ADD_PRODUCT_CAT)

RewriteRule ^(.)-c-(.).html$ $1-c-$2/ [R=301,L]
RewriteRule ^(.)-c-([^/]+)$ %{REQUEST_URI}/ [R=301,L]
RewriteRule ^(.
)-c-([^/]+)/$ index.php?main_page=index&cPath=$2&%{QUERY_STRING} [L]

RewriteRule ^(.)-m-([0-9]+).html$ index.php?main_page=index&manufacturers_id=$2&%{QUERY_STRING} [L]
RewriteRule ^(.
)-pi-([0-9]+).html$ index.php?main_page=popup_image&pID=$2&%{QUERY_STRING} [L]
RewriteRule ^(.)-pr-([0-9]+).html$ index.php?main_page=product_reviews&products_id=$2&%{QUERY_STRING} [L]
RewriteRule ^(.
)-pri-([0-9]+).html$ index.php?main_page=product_reviews_info&products_id=$2&%{QUERY_STRING} [L]
RewriteRule ^(.*)-ezp-([0-9]+).html$ index.php?main_page=page&id=$2&%{QUERY_STRING} [L]

All other pages

Don't rewrite real files or directories

RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*).html$ index.php?main_page=$1&%{QUERY_STRING} [L]

Handle when a resource is not found (404 Error Page)

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?main_page=page_not_found&%{QUERY_STRING} [L]

17 Aug 2013, 2:49 PM
#10
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: website always redirect to ww6 or js

helpoftcm:

For the website, I found .htaccess file and I removed it, but that didn't help, there is still redirection and can not see the website.

Did you clear/refresh your browser cache after removing this? (this needs to be done after making pretty much any site changes)

If so, then proceed to step#2
"If the problem persists after performing step#1, use the Developers Toolkit and look for any hard coded links to the erroneous URL's"

This will take you about 30 seconds. I don't think you'll find anything though, because to me, it still looks like a URL rewriting issue, AKA, the .htaccess file.

In fact the copy of the .htaccess file you posted appears to be missing some important elements... specifically, it has lots of rewrite rules, but no rewrite conditions to match those rules. I don't know if this is normal for 'Ultimate SEO URLs' or not. Either way, the suggestion to remove/rename the .htaccess file isn't/wasn't designed to be a complete/proper cure for the problem. It is/was designed to provide us with feedback as to whether this is the cause (or not).

If we can trust your report that removing this file** really** doesn't make any difference, then we can eliminate this file as being the root cause of the problem and we can totally ignore it and look for the 'real' cause.

Also, what can you tell us (if anything) about "ww9". Is this something that you have configured/defined somewhere, such is an your configure.php files?
Can you post a copy of both of your configure.php files (taking care to blank out any account/login details).
I'm not saying that 'ww9' is wrong for a hostname, but I can tell you that if it is a valid hostname then things won't work anyway, because there isn't a DNS entry for ww9.nikogems.com (there is an entry for jp.nikogems.com though, which is the other URL you say it is being redirected to).
I guess I have the same question about this one too though... where does the 'jp' hostname actually come from? Is this something your host told you to use or what?

I originally thought this would be an easy one to solve, but now I'm not so sure. I've managed to come up with more questions than answers :(

Cheers
Rod

17 Aug 2013, 3:19 PM
#11
helpoftcm avatar

helpoftcm

New Zenner

Join Date:
Jul 2009
Posts:
7
Plugin Contributions:
0

Re: website always redirect to ww6 or js

I confirm that it redirects to ww6 and ww9 after refreshing the browser.
I still can not go to Zen cart admin, only through FTP client.

Sometimes it show js. not jp. Can it be java script?
I will look for configure.php files and post it here...

17 Aug 2013, 3:28 PM
#12
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: website always redirect to ww6 or js

helpoftcm:

I confirm that it redirects to ww6 and ww9 after refreshing the browser..

Repeat:
What can you tell us (if anything) about "ww9". Is this something that you have configured/defined somewhere?

Where does the 'jp' hostname come from? Is this something your host told you to use or what?

helpoftcm:

Sometimes it show js. not jp. Can it be java script?

I'll make a deal with you. If you answer my questions I'll answer yours :)

Your line of thinking is jumping well beyond where you need to be at this point in time.

Cheers
Rod

17 Aug 2013, 4:19 PM
#13
rixstix avatar

rixstix

Totally Zenned

Join Date:
Aug 2009
Location:
North Idaho, USA
Posts:
2,015
Plugin Contributions:
0

Re: website always redirect to ww6 or js

Could it be related to a subdomain or addon domain in cPanel @ host level?
Could it be related to forwarding @ the registrar level instead of host level?

neither of which would necessarily be seen in any zencart related code?

Says he with just enough know-how to be dangerous :blush:

18 Aug 2013, 2:42 PM
#14
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: website always redirect to ww6 or js

RixStix:

Could it be related to a subdomain or addon domain in cPanel @ host level?

Not by itself no.
However, the URL's are being redirected to a different host (in yours, and cPanel teminology, a 'host' is a subdomain/addon domain, which is technically incorrect and somewhat misleading).

RixStix:

Could it be related to forwarding @ the registrar level

I'm really not sure what you mean by this. Registrars are, well, registrars. All they do is register the domain names. There is no such thing as 'forwarding @ the registrar level'.

Perhaps you are thinking of the DNS 'CNAME' records? (nothing to do with the domain registrars)
Even these don't do any forwarding or redirections. They simply tell the DNS that the CNAMED host has the same IP address as the primary host.

RixStix:

Says he with just enough know-how to be dangerous :blush:

No comment :D

Cheers
Rod

18 Aug 2013, 4:44 PM
#15
rixstix avatar

rixstix

Totally Zenned

Join Date:
Aug 2009
Location:
North Idaho, USA
Posts:
2,015
Plugin Contributions:
0

Re: website always redirect to ww6 or js

RodG:

I'm really not sure what you mean by this. Registrars are, well, registrars. All they do is register the domain names. There is no such thing as 'forwarding @ the registrar level'.

Perhaps you are thinking of the DNS 'CNAME' records? (nothing to do with the domain registrars)
Even these don't do any forwarding or redirections. They simply tell the DNS that the CNAMED host has the same IP address as the primary host.

Cheers
Rod

All I know is that I have 2 dozen domains with a single registrar. 23 of those domains are 'forwarded, permanent 301' to a single primary domain where my zen-cart installation exists. I use a screen, while logged into my account with my domain registrar, that says "Forward" and that screen is independent of any 'CNAME' screen or link.

May not be the 'proper' terminology but that is the labeling of the fields that I populate within my domain registrar account which is completely different from my hosting account established elsewhere.... thus my calling it @ the registrar level to distinguish the settings from those being made within a cPanel hosting account.

19 Aug 2013, 3:34 AM
#16
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: website always redirect to ww6 or js

RixStix:

All I know is that I have 2 dozen domains with a single registrar. 23 of those domains are 'forwarded, permanent 301' to a single primary domain where my zen-cart installation exists. I use a screen, while logged into my account with my domain registrar, that says "Forward" and that screen is independent of any 'CNAME' screen or link.

May not be the 'proper' terminology but that is the labeling of the fields that I populate within my domain registrar account which is completely different from my hosting account established elsewhere.... thus my calling it @ the registrar level to distinguish the settings from those being made within a cPanel hosting account.

This is one of those times it would be great to be able to split this off to another thread, but since that isn't possible, and I don't wish to contaminate the thread with an irrelevant discussion, I will ask that you simply read (and hopefully accept, follow and understand) what I'm about to say and move on.

Before saying more..... helpoftcm..... please skip this message. It has nothing to do with your problem.

RixStix, You stated you had "just enough knowledge to be dangerous" and I'm hoping to take you to the next steps to avoid the dangers you fear. Not only that, I'm going to give you a tip or two that could provide a noticeable increase in the performance of those 23 sites you mention. Sound good? Read on.

First point of issue. The 'forwarded, permanent 301'is a function of a web server application. It is totally unrelated to anything else on the internet, which includes the registrars, the DNS and even other (non web) applications such as FTP, SSH, Telnet, etc.

Second point if issue. The type of forwarding that you have invoked is probably quite pointless. The only practical purpose for it is if it is impossible to perform any needed redirections on the host server.

What is happening with these 'registrar forwards' isn't any different than what goes on with the localhost redirects, it just adds another WEB server to the mix, and this will have a negative performance on your sites(s).

With your current configuration (using 'registrar redirect') a browser/client connecting to your site will first perform a DNS (name to IP address) lookup, and this will provide the IP address for your** registrars web server**. The browser will then connect to this WEB server, which then sends a message stating 'The site you want no longer exists here, but you can find the new location this URL'
The browser/client then has to perform another DNS lookup for this 'new' location, which will be the IP address of where your sites are hosted, and finally the client can retrieve and display the page.

It makes MUCH more sense to forgo this needless 'registrar forwarding' so that when a client tries to connect to your site, it performs the DNS lookup that returns the IP address of your site, and bob's your uncle, the site/page will be displayed with very little delay, only a fraction of the processing needed to get there, and you won't be at the mercy of the registrars webserver being functional at all times which is essential to keeping your sites 'live' at all times. IOW, it is one less point of failure.
FWIW, many registrars don't/won't even offer this type of forwarding as one of their services. There is (generally) no need for it (in fact once the domain name registration has taken place and the name servers defined, the registrars are effectively out of the picture as far as anything else goes. They only need to supply the domain name and NS records to the TLD's (top level domains) and notify them of any changes. The records are passive rather than dynamic.

Another issue with the 'registrar forwarding' is, as stated, this is a function of a webserver, so what is going to happen if someone tries to connect to your host using an FTP client rather than a Web client? The FTP client will perform the DNS lookup for your site, receive the IP address for your registrars server, and since the FTP requests aren't forwarded like the WWW requests, the FTP client will end up trying to connect to the registrars FTP server rather than your own.
If you haven't noticed this effect it means that you are telling your FTP clients to use the host IP address rather than the domain name, OR, most likely, your DNS records contain a specific entry for 'ftp.yourdomain.com' which maps to your hosts IP rather than the registrars.

Now lets assume you have more than one domain name and that you want them both/all to be hosted on the same server? There are a couple of ways to do this with DNS records. You can give each domain name the same IP address as an 'A' (Address) record, or you can give just one of them an 'A' record, and the others 'CNAME' records. In this case, CNAMES are prefered (less maintenance should you ever need to relocate to a different host. Only one 'A' record to change, and the others will follow). Again. no need for any forwarding or multiple DNS lookups, but the same end result (albeit, a lot more responsive).

Now, if this isn't enough to convince you of the 'error of your ways', perhaps I can pique your interest by mentioning 'Google rankings'. It is a well known fact that given two identical sites, one that is to be found with a single DNS/IP lookup and the other with a redirection in place, the site without the redirections will always get a higher ranking. I try to avoid redirections where possible for this reason alone.
Technically any form of web redirect is a 'bad thing'. Its purpose is/was to provide a means of keeping a site (or pages) online and available if/when a change on a site is made that would normally break existing links. It was never ever designed to be something to be used with an initial server setup (which wouldn't need any redirects in the first place), yet that is exactly what you have done. Essentially you are telling the clients that the site has already been moved even though it was a brand new site.

I hope you find this somewhat informative. As I say, I have no intention of having a full on discussion about it. I'm not telling you anything that can't be easily verified and checked from informed sources.

Oh, I must add, I'm only speculating that you probably don't need the 'registar redirects', there ARE times where this may be the only option though... such times are rare though.

Cheers
Rod.

19 Aug 2013, 1:14 PM
#17
rixstix avatar

rixstix

Totally Zenned

Join Date:
Aug 2009
Location:
North Idaho, USA
Posts:
2,015
Plugin Contributions:
0

Re: website always redirect to ww6 or js

I didn't ask for help. I didn't contaminate the thread with an unrelated diatribe. I just offered a suggestion that the cause of the symptoms being experienced by the OP could be outside of zencart code or outside of the OP hosting account.

22 Aug 2013, 10:53 AM
#18
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: website always redirect to ww6 or js

RixStix:

I didn't ask for help

I know that.

RixStix:

I didn't contaminate the thread with an unrelated diatribe.

I know that.

RixStix:

I just offered a suggestion that the cause of the symptoms being experienced by the OP could be outside of zencart code or outside of the OP hosting account.

I offered a response stating why this wouldn't be the case. I wasn't trying to put you down or upset you in any way shape or form.

On the contrary, you made statement that had me thinking that there was a good chance that I could do you a favour by suggesting a way to to improve the performance and reliability of your site(s). Was that such a bad thing for me to do?
When did the world change whereby one person can't help another unless explicitly asked?

Anyway, I do apologize if I upset or offended you.

I do still think I can do you a favour though, but clearly I need a different approach, so instead of trying to explain things, I'm hoping a few practical examples will show where you are, and where I'm trying to 'lead' you (Yeah, I know, I can lead a horse to water, but I can't make him drink).

Listed below are four different configuration 'problems' and their solutions. Unless I'm very much mistaken, you have configured your site(s) using problem/solution#4, where for best reliability and performance, you should be using solution#1.


Problem#1. How to make this work? (This is the most common scenario)
demo.com ->Registered at "cheapdomains"
demo.com ->Website hosted at http://somehost.com. (You can use your own domain name).
demo.com ->All mail handled by somehost.com

Solution:
Delegate NS1.cheapdomains.com & NS2.cheapdomains.com (at the registrar for the demo.com domain name)

Add the following NS records for demo.com on the cheapdomains.com nameservers
demo.com IN A 20.20.30.40 ; IP Address where site is hosted
www. IN CNAME demo.com ; An 'Alias' for people that think 'www' is essential
ftp. IN CNAME demo.com ; FTP and webserver on same host. Easy maintenance.
demo.com IN MX 10 demo.com ; primary mailserver
demo.com IN MX 20 demo.com ; secondary mailserver


Problem#2. How to make this work? (This is a complex scenario)
demo.com ->Registered at "cheap domains" (Doesn't allow 'domain forwarding'. Doesn't have a DNS configuration tool. Doesn't provide Web Hosting. )
demo.com ->Website hosted at http://free########################/blogs/demo/ (Provides free web hosting only. No email. You can't use your own domain name.
demo.com ->All mail to be handled by Google.com

Solution:
Delegate NS1.3RD_PARTY.COM & NS2.3RD_PARTY.COM (at the registrar for the demo.com domain name)

Add the following NS records for demo.com on the 3rd party nameservers
demo.com IN A 10.20.30.40 ; Address of URL redirection Web server
www. IN CNAME demo.com ; An 'Alias' for people that think 'www' is essential
ftp. IN A 200.1.2.3 ; Address of free######################## where demo.com is hosted
demo.com IN MX 10 aspmx.l.google.com ; primary mailserver (google)
demo.com IN MX 20 alt1.aspmx.l.google.com ; secondary mailserver (google)
demo.com IN MX 30 alt2.aspmx.l.google.com ; tertiary mailserver (google)

Then add this to the .htaccess file of the redirection server (10.20.30.40) :

RewriteEngine on
RewriteCond %{HTTP_HOST} ^demo.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.demo.com$
RewriteRule ^(.*)$ "http://freewebhost.com/blogs/demo/$1" [R=301,L]


Problem#3. How to make this work? (A rather unusual scenario)
demo.com ->Registered at "cheapdomains" (With 'domain forwarding')
demo.com ->Website hosted at http://somehost.com/yousite/.
demo.com ->All mail handled by somehost.com

Solution
Delegate NS1.cheapdomains.com & NS2.cheapdomains.com (at the registrar for the demo.com domain name)

Add the following NS records for demo.com on the cheapdomains.com nameservers
demo.com IN A 20.20.20.40 ; Address of URL redirection Web server (cheapdomains.com)
www. IN CNAME demo.com ; An 'Alias' for people that think 'www' is essential
ftp. IN A 1.2.3.4 ; FTP Address of somehost.com (where demo.com is hosted)
demo.com IN MX 10 somehost.com ; primary mailserver
demo.com IN MX 20 somehost.com ; secondary mailserver

Then add this to the .htaccess file of the redirection server (cheapdomains.com):

RewriteEngine on
RewriteCond %{HTTP_HOST} ^demo.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.demo.com$
RewriteRule ^(.*)$ "http://somehost.com.com/yoursite/$1" [R=301,L]


Problem#4. How to make this work? (See note/comment below)
demo.com ->Registered at "cheapdomains" (With 'domain forwarding')
demo.com ->Website hosted at http://somehost.com/
demo.com ->All mail handled by somehost.com

Solution:
Delegate NS1.cheapdomains.com & NS2.cheapdomains.com (at the registrar for the demo.com domain name)

Add the following NS records for demo.com on the cheapdomains.com nameservers
demo.com IN A 20.20.20.40 ; Address of URL redirection Web server (cheapdomains.com)
www. IN CNAME demo.com ; An 'Alias' for people that think 'www' is essential
ftp. IN A 1.2.3.4 ; FTP Address of somehost.com (where demo.com is hosted)
demo.com IN MX 10 somehost.com ; primary mailserver
demo.com IN MX 20 somehost.com ; secondary mailserver

Then add this to the .htaccess file of the redirection server (cheapdomains.com):

RewriteEngine on
RewriteCond %{HTTP_HOST} ^demo.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.demo.com$
RewriteRule ^(.*)$ "http://demo.com/$1" [R=301,L]

However, This scenario is exactly the same as "problem#1". Redirects aren't needed in this case, so why use them?

Note#1: The .htaccess additions are (generally) performed automatically whenever URL forwarding is configured
using the server admin tools.

Note#2. Please take careful note of Problems#2 & #3. These show the only situation where 'domain forwarding' is a
required part of the solution. However, it is also a rare and unusual situation that will only occur with a
hosting site that doesn't allow you to use your own domain name (typically, a 'free' server).

Use this info as you see fit.

Cheers
Rod.
ps. "Registrar forwarding" == "Domain forwarding"