I've read lots about what can be done with mod_rewrite but I haven't found one to solve my problem. Maybe it can't be done?
I have a sub-domain on my primary domain that I have a customer direct user to to use one of my programs. The customer doesn't want his customers to see that that are on my domain and he doesn't want to use an iframe.
So, is it possible for the user to only see www.subdomain/program.php instead of www.subdomain.mydomain.com/program.php?
If you want the browser to show www.subdomain/program.php in its location bar, you need to register the www.subdomain domain name. There is no way to remove bits of the domain name using anything in the htaccess file. For example, if you've registered example.com and you have a server at foo.example.com, and you want to be able to go to http://foo/some/path/index.html, you're out of luck because the browser is going to attempt to do a DNS lookup of foo and it will most likely fail unless there happens to be a "foo" server under the DNS search domain. Browsers put a great deal of effort to prevent spoofing of the domain name, since it would be really bad if I was able to spoof my website to show the domain of a bank in a browser's location bar while actually visiting an entirely different website.
Related
I had an argument with my friend about domain redirects. He is convinced that you can redirect one domain to another by using DNS records only, showing source URL in browser instead of target URL. I mean, without any access to webserver. I don't think this is the case but can't find a direct proof that it's impossible.
So I'm curious. Is there a way to do it?
Yes it's possible. It's sometimes called Stealth Forwarding and may or may not be offered by your domain name registrar.
We have old domain name which we would like to redirect the traffic to new domain
e.g.
old.domain.com --> new.domain.com
Help/Clarification:
What's the best way to achieve this? Read about CName, ARecord, Alias etc., therefore confused which one to use and which scenario.
If we redirect old.domain.com to new.domain.com, then what will IIS/Web Server see as requested host name i.e. still sees old.domain.com or new.domain.com
If you want to redirect the traffic, i.e., you want the customer's web browser to show the change from "old.domain.com" to "new.domain.com", then you'll need to insert that redirect at the web server or code level.
If you simply want a request for "old.domain.com" to land on the address for "new.domain.com", then you can use just a CNAME in DNS.
What is best practice for doing this? Should I have duplicate content at each domain or should I redirect from one to the the other, i.e. all traffic to the .co.uk domain redirected to the .com domain?
Best practice is to send them all to one web server.
By default the server will not care which domain is pointed at it and will show the home page as domainx.com if you to it from domainx.com.
However there are two possible issues with this that come to mind:
The person who created the website hopefully only used relative links. (The contact us button points to contactus.htm instead of http://domainx.com/contactus.htm ) If not, some links might change the user from domainx.co.uk to domainx.com.
Search Engine Optimisation: Its better SEO wise if all the links to your site point to one domain name rather than appearing as several less popular sites.
You can get everyone on the same site by using a RewriteRule or 301 Redirect to the primary site. Or you can make every hyperlink on the site absolute and point to the primary domain.
i am a user, and i type: www.japsomething.com, that url doesn't exist however there is a folder called "something" and i want this url to point to that folder?
do i need to purchase the domain name for this to work or i can use .htaccess?
i still would like to preserve the url. so this means, even though i am coming from
www.japsomething.com the url should still say www.japsomething.com and when i click anything on the site it should say www.japsomething.com/anything/
another question is, how can i detect based on the users ip that i want to show them a spanish site, or an english site?
thanks for your responses.
do i need to purchase the domain name for this to work or i can use .htaccess?
You need to purchase the domain name, because otherwise when someone types: www.japsomething.com, their DNS is going to try to look that name up, and if you don't own that domain, the request is never going to reach your server, thus, your htaccess file is never even used. Because you don't own every domain that starts with "jap" and ends with ".com", you can't use htaccess to do this.
i still would like to preserve the url. so this means, even though i am coming from www.japsomething.com the url should still say www.japsomething.com and when i click anything on the site it should say www.japsomething.com/anything/
If you own the "japsomething.com" domain, you simply point it to the server and directory that contains all the content, and then be done with it. No htaccess trickery is involved here. If you went out and bought the "japsomethingelse.com" domain, simply point it to the directory that serves that.
another question is, how can i detect based on the users ip that i want to show them a spanish site, or an english site?
See mod_geoip2 for downloads and examples.
Our client would like to use just one domain name for their site to prevent diluting page rank in search engines.
For example, stackoverflow.com is the domain name they always use. If you type in www.stackoverflow.com you get redirected to the non-www version, as this is their choice for their domain name.
Where should this be done?
At the application server level (ex in IIS, set up a site and have it issue a permanent redirect to the proper domain name
At the application level
I don't like #1 as it means I have a bunch of extra sites set up just for redirecting. I don't like #2 as rewrite rules do affect performance.
thanks.
Do it at as low a level as you can possibly do it. Your application shouldn't know about its root domain name.