IIS rewrite subfolder URL to subdomain content - iis

I'm trying to load content hosted on a subdomain site as a subfolder on the same main domain - I've attempted a variety of IIS URL rewrites with no luck so far. The goal is for a user to go to:
domain.com/subdomain1
which displays
subdomain1.domain.com
but keeps the URL as
domain.com/subdomain1
There are multiple subdomains which I need to do this with.
I have the URL Rewrite module installed and have tried all many of rules.
Any help would be appreciated :-)

A rewrite changes the path on the server only, if you want the URL to change you need a redirect. You can change this on the rule.

Related

domain name with or without 'www'

I have a domain e.g. named www.example.com, when people type in example.com, it still can be accessed, but won't automatically add that 'www' to the url.
But as for website like facebook, if you type in facebook.com, it'll automatically add that 'www', BEFORE loading the page for you.
Probably I didn't explain it well, but guess you see the difference and get my point anyway.
So how can I make my domain acts like facebook, when people type example.com, it'll automatically add that www for them?
EDIT:
Ok, so I need a redirect to the 'www' subdomain. Actually I'm using nodejs, which hosted on Amazon EC2, to serve the webpage instead of Apache HTTP. So any equivalent of .htaccess in nodejs area?
I guess now the question shifts to more nodejs oriented, and it turns out it becomes a redundant of this thread:
Redirect all requests using Express 3?
Thanks all for your help.
you have to set your domain 301 permanent redirect in your control panel.
if your website is hosted in CPANEL then
GOTO -> Redirects in ( Domains Menu )
Choose the type Permanent (301)
choose your domain.com
www.domain.com in redirects to→ __
check the box on Redirect with or without www
finally CLick ADD
if your website is hosted in PLESK then
do it in your program level
or
plesk11.0.29 version above supports the 301 peramanent
You can do all of this with a .htaccess file.
https://kb.mediatemple.net/questions/242/How+do+I+redirect+my+site+using+a+.htaccess+file%3F
# This allows you to redirect your entire website to any other domain
Redirect 301 / http://mt-example.com/
Add this in a file named .htaccess on your host, but set it to the URL you want your main page to be.
To make a .htaccess file, you can always go in FTP, upload an empty .txt file, open it with notepad, put in the lines of code above, then rename it to .htaccess.

how to make clean url using htaccess for subdomain

for e.g. my domain is www.examples.com and subdomain is test2.examples.com
I am using url variable to link pages.
e.g.test2.examples.com/index.php?page=registers
but I want clean url like
test2.examples.com/page/registers
How can I do this using HTACCESS file.
can I use HTACCESS for subdomain or it will not allow
You are looking for URL Rewriting, it will answer all your needs., see this URL Rewriting Guide

forwarding domain with htaccess but keep the url structure

I have a parked domain www.my-domain.com
I also have a hosted active domain sub.active-domain.com
I want to forward www.my-domain.com to sub.active-domain.com but keeps the url on
structure in the browser from sub.active-domain.com
example:
sub.active-domain.com/content/market.html
will shows on url become
www.my-domain.com/content/market.html
how to do it thru the htaccess file ? or should i do it thru the DNS or CNAME ?
The best way would be with .htaccess.
But you can not keep the url as long as you redirect it somewhere.
Or other wise use a iframe.

subdomain url using .htaccss

This is my website url http://mywebsite.com
I create an another website but this website's url would be http://mywebsite/mynewwebsite.com
Please help to find the solution using .htaccess file.
That's impossible. You can do http://mywebsite.com/mynewwebsite/ or http://mynewwebsite.mywebsite.com/ but not what you're asking.
Furthermore, I don't think you can set up subdomains simply using htaccess.

IIS URL Rewriting for all Inbound URLs?

Hopefully a simple question although one I have found impossible to answer myself using the Googles!
I have a website on IIS with the URL http://www.contoso.com/ which points to C:\www\public\
There has been a forced directory restructure so now all of the data (Default.aspx, Product.aspx, etc.) that originally resided in C:\www\public\ now resides in C:\www\public\en\ie\ - however, the IIS website document root is still C:\www\public\
So, essentially, I have a lot of inbound links to http://www.contoso.com/Product.aspx?id=1 (etc.) which are now returning 404 errors - the correct link is now http://www.contoso.com/en/ie/Product.aspx?id=1
Please consider that I can make no changes to the directory structure or the IIS document root... so I must solve this issue using URL rewriting.
Is it possible to capture all requests to contoso.com/* and rewrite them to contoso.com/en/ie/* ??
As Ivo suggests, using url rewriting you can set up inbound rules that match the old url pattern and redirect to the new pattern
http://learn.iis.net/page.aspx/460/using-url-rewrite-module/
Change the root directory of your website from C:\www\public\ to C:\www\public\en\ie\ and everything should be fine.
If you cannot do this for any reason, make a custom 404 page and rewrite to url in there and redirect with a 301
See: http://searchengineland.com/url-rewriting-custom-error-pages-in-aspnet-20-12234

Resources