Say I've got two distinct domains:
1) http://sub.test.org
2) http://m.sub.test.org
for my website.
I want domain n.1 to be associated to the full-version of my website (intended to be mainly visited by desktop user agents) and domain n.2 to be associated to its mobile-version (intended to be mainly visited by mobile user agents).
Both of the versions reside on an external host which runs an instance of Apache webserver I can't control directly, but I am able to post .htaccess files and therefore I want them to control domain redirecting stuff (I don't want to use Javascript neither PHP server-side logic)
The directory structure on the external host is, say:
directory / --> contains full-version website's pages and resources
(index.html is the entry-point)
directory /mobile --> contains full-version website's pages and resources
(index.html is the entry-point)
and the mappings are:
http://sub.test.org -> /index.html
http://m.sub.test.org -> /mobile/index.html
Now, my desired scenarios are as follows:
A) When user asks for URL http://sub.test.org:
IF current URL is http://m.sub.test.org/* (this means: if user is currently into the mobile-version) THEN serve page http://sub.test.org/index.html
ELSE:
IF user agent is mobile THEN redirect to URL http://m.sub.test.org
ELSE serve page http://sub.test.org/index.html
B) When user asks for URL http://m.sub.test.org - no matter what the user agent is - user should be redirected to URL http://sub.test.org.
My questions:
What would be the syintax of the associated .htaccess file?
Do I need more than one?
Where should I place it/them ?
Any help/code hint would be really appreciated, because I have really a few experience with Apache .htaccess files and regexps! Thanks in advance.
http://httpd.apache.org/docs/current/howto/htaccess.html
You would most likely need 2
place one it in the root and one in /mobile
Related
I am trying to use multiple domains on the same webserver but get a different website depending on the domain which was entered. I think this is possible using HTACCESS but I couldn't find anything useful on google.
Here is an example:
www.a.com -> index.php
www.b.com -> /b/index.php
But if someone wants to view B the URL should still be www.b.com with no trace of www.a.com.
i am having a small custom built web app in PHP/MySql. i want to make it white label by allowing others (my selected clients) to point their subdomain to that app.
i have :
www.MainSite.ab and www.MainSiteAddonDomain.abc.ab
i want :
subdomain.myclientsite.com --> (mywebsite)/subfolder/
and address bar should show my clients url instead of my website like
subdomain.myclient.com/subfolder/
what i did:
i added a (CNAME / A) record at myclient.com to my servers (domain / IP) and then in my main website i added a parked domain (subdomain.myclient.com) and then in manage redirected i redirected it to /subfolder/
it all worked well BUT
if i open subdomain.myclient.com/index.php then it would open www.MainSite.ab that i dont want to open since it exposes our brand and violate white labeling. (this could be possible via .htaccess i guess)
what is the right way to achieve this ? since parked domains home directory is always at main domains home directory.
one thing more, the www.mainsite.ab/subfolder/ includes some library resources that are placed at www.mainsite.ab/library/ folder.
I am currently having two domains www.xyz.com and www.pqr.com. If anybody enters xyz.com I need to bringout the website pqr.com
Both are on the same server.
Kindly suggest how to go about this.
Thanks
In internet services manager, right
click on the file or folder you wish
to redirect then select "Properties"
Select the radio titled "a redirection to a URL".
Enter the redirection page
Check "The exact url entered above" and the "A permanent redirection for this resource"
Click on 'Apply'
From http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/6b855a7a-0884-4508-ba95-079f38c77017.mspx?mfr=true
To redirect requests to another Web
site or directory
In IIS Manager, expand the local computer, right-click the Web site or
directory you want to redirect, and
click Properties.
Click the Home Directory, Virtual Directory, or Directory tab.
Under The content for this source should come from, click A redirection
to a URL.
In the Redirect to box, type the URL of the destination directory or
Web site.
If you want to say that "you should always go to foo instead of bar," you want a 301 redirect (which you do with your front-end server). See http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=93633
A 302 (temporary) redirect should be used in cases where you can't serve a page, but expect it to come back later. Unfortunately, it's the redirect that you get from JSP forward.
A client-side (meta refresh or javascript) redirect should be avoided whenever possible.
Apache docs for configuring a permanent (or temporary) redirect.
If you want pqr.com to appear in the user's browser's address bar, you'll have to send a 301/302 redirect response, either through a script or through your web server's configuration - how to do this depends on what software you are using.
If you are using IIS7 and you have installed URL Rewrite Module then use this article for more information : IIS URL Rewrite – Redirect multiple domain names to one
I have a Windows 2008 Server with IIS7 on it and a web page running under the name, let's say myApplication. I have a domain name that points to the IP of my server, let's say myApplication.com.
In order to access my application I have to enter http://myApplication.com/myApplication.
If I write http://myApplication.com/ I arrive to the IIS7 start page. Is there a way (besides rewriting the iisstart.htm to make a JavaScript or meta-data redirect) to automatically open the myApplication when someone enters "http://myApplication.com/"?
What I would like is the following:
The user enters in the browser: "http://myApplication.com/"
He/she is taken to "http://myApplication.com/myApplication"
In the URL bar of the browser only "http://myApplication.com/" shows and everything inside the application is relative to this URL.
Generally when I configure IIS, I set the properties for the "default web site" to a folder that doesn't contain anything, then create individual entries within IIS for each web site. For example, you would create a new entry for "MyApplication.com" and set its home directory to the proper folder on the server that contains your root files (usually c:\inetpub\wwwroot\myapplication.com\ but it could be anywhere you like).
It sounds as if you have created a folder for your application, but do not have a specific entry in IIS configured to handle the requests and load files from the proper folder.
If you have a dedicated IP address for the application, be sure to specify that IP within the site settings for that site. If you're using a single IP for multiple sites, configure the IP AND hostnames/domains that will be used to access that site so IIS will know which site entries belong to which domains and where to route the requests.
I currently have 2 domain names that I want to setup different websites for. I am currently looking at using some free hosting that works well for my current needs but doesn't give me any way to point "mydomain.com" to the actual site. Instead I have to give users a longer, harder to remember url.
My proposed solution is to point my domains to my home ip and host a small ASP.NET app through IIS consisting of a redirect page that simply redirects to the appropriate site. Is there a way in ASP.NET to recognize which domain url was requested in order to know where to redirect the page to?
Here is one way to do it (as recommended by 1and1.com if you host multiple domains). Put this at the root of your web space. All of your websites will point to this root. The script below will forward the requests to the proper subfolder. It's kind of a hack, but if you don't have complete control over the IIS settings, this will work.
Name this file default.asp:
<%EnableSessionState=False
host = Request.ServerVariables("HTTP_HOST")
if host = "website1.com" or host = "www.website1.com" then
response.redirect("http://website1.com/website1/default.aspx")
elseif host = "website2.com" or host = "www.website2.com" then
response.redirect("http://website2.com/website2/default.aspx")
else
response.redirect("http://website1.com/")
end if
%>
From asp.net code you can access the host from the request object:
if(Request.Url.Authority == "www.site1.com")
Response.Redirect(...);
If you have access to the IIS server you can also set up two sites with different binding host names and have each redirect as you like.