how would i go about implementing something like the following...
example.com site has these pages:
example.com/id1/page1/
example.com/id1/page2/
example.com/id1/page3/
example.com/id2/page1/
example.com/id2/page2/
example.com/id2/page3/
and now i want to have that when i point domains example1.com and example2.com to example.com/id1/ page and example.com/id2/page1/ respectively.
the site is on azure and what i did was set a dns for all three domains (example.com, example1.com, example2.com) to point to the same ip.
and then on the home page of the site i do a redirect with
Response.Redirect(...);
but this means that the domains example1.com and example2.com are not seen in the browser url, but rather the urls such as example.com/id1/ and example.com/id2/ are seen instead.
what i would instead like is to have my site show as the actual domain in such a way that these URL's are never seen:
example.com/id1/
example.com/id1/page1/
example.com/id1/page2/
example.com/id1/page3/
example.com/id2/
example.com/id2/page1/
example.com/id2/page2/
example.com/id2/page3/
and instead they respectively show up as as
example1.com/
example1.com/profile/
example1.com/about/
example1.com/contact/
example2.com/
example2.com/profile/
example2.com/about/
example2.com/contact/
so what do i need to change to make the domains visible as such?
sorry for the long question :( hope you can help me.
You wouldn't do that using a redirect since, as you mentioned, you want to keep the URL displayed as the one typed in. What you are trying to do is URL routing. For ASP.NET, the process and configuration is explained here: http://msdn.microsoft.com/en-us/library/cc668201(v=vs.100).aspx
If your list of pages is limited, you can do routing statically. Or you can provide the route table based on a database of pages or something. The walkthrough here explains how to provide those routes: http://msdn.microsoft.com/en-us/library/dd329551(v=vs.100).aspx
Related
I purchased the "real" domain name for my website and I'd like to re-direct all traffic that was going to the old site, to the new site.
Here's the scenario: I currently have http://www.wrestlestats.com, but I want to start having everyone use http://www.wrestlestat.com (note without the "s" on the end).
All of google (and I'm assuming all other search engines) return my results for the old site (with the "s").
From what I've read here, everything is just telling me to put a 301 re-direct either on the page (html meta), or in a web.config, or in the Page_Load code in the controller.
My problem is, these are assuming the old "code" is completely separate and sitting on a different server. No, I have 2 domains pointed to the same site/code. If I place the re-direct in the html meta section, then my page will just keep looping. I'm running ASP.NET Core so I don't have a web.config.
What to do for people running ASP.NET Core?
Just do it in 2 steps ---
Configure new domain (instead of old one)to your site.
Use Forward Domain from your domain control panel with the option of path forwarding.
Forward:-
http:-//www.wrestlestats.com > http:-//www.wrestlestat.com
Just having a problem trying to properly display an image from an external site but mvc constraints links and automatically adds the localhost: url at the start of everything even with custom routing this cannot be avoided
eg I require: www.google.com/finance/chart?q=NYSE:V&tlf=12
but i am getting: http://localhost:3022/www.google.com/finance/chart?q=NYSE:V&tlf=12
any help would be much appreciated
Your problem is not MVC; it is the formation of your <a> tags. You are doing it like this:
blah...
You should be doing it like this:
blah...
Without including the protocol at the beginning, the browser assumes your link is relative to the current site. It has nothing whatsoever to do with MVC.
If you require a link on a separate domain, you need to add http://
So :
http://www.google.com/finance/chart?q=NYSE:V&tlf=12
Should work!
Why? Without the http, the link is considered relative and the browser uses the relative domain -> localhost!
I'm working on a real estate website. It would be ideal to have my client's featured properties have their own unique URL like:
www.realestatewebsite.com/featured/123-fake-st/
I'm constructing a CMS for my client so that they can add/delete featured properties in an admin backend, meaning that I need to write a program to automatically add the new URL for them based on the address they input in the database through the CMS.
I'm new to URL Rewrite. What would be the best way to go about this? I've considered using RewriterConfig in the web.config, but then I'm worried I would encounter problems writing a program that adds new rules to the web.config file. I thought about using a regex expression in the RewriterRule to find anything after /featured/ in the URL, but then if I'm just using the address in the LookFor then how would it know which property ID to use in the SendTo?
It would be ideal if I could just have a file put the address after "/featured/" into a string, look in the database for the address and retrieve the Property ID and then redirect the users that way.
As I said, I'm new to URL Rewriting and it would be great if someone could point me in the right direction.
Thanks!
-Aaron
There are different ways of doing this. Common to all solutions are the following:
Set up a algorithm to create the URIs and store them in the database (changing space to - is a simple way to achieve this.
Route the URI by making the address string into a parameter
Routing can be done a variety of ways.
If you have control of the server, or they have control of the server, you have the ability to set up IIS rewriting on the IIS instance on their server (good starter URI).
If this is hosted on an ISP, you may not have this option and have to use IIS rewriting and will have to use ASP.NET routing. Here is a good article to start with to undestand this. If you are using MVC, the routing is "built in".
I would suggest using URL Rewrite Module for IIS7, look here:
http://learn.iis.net/page.aspx/460/using-the-url-rewrite-module/
I give to google a sitemap with all my pages, when the crawler tries to access them he gets redirected to the login page.
In the login page I write an explanation of what the page does so the crawler can see that each page is different.
The problem now is that the bot is clever enough as to recognize that it is a redirect:
URLs not followed
When we tested a sample of URLs from your Sitemap, we found that some URLs redirect to other locations. We recommend that your Sitemap contain URLs that point to the final destination (the redirect target) instead of redirecting to another URL.
HTTP Error: 302
If instead of using a redirect in RedirectToLoginPage(String), Microsoft had used a Server.Transfer, google would never find out it is actually the same page.
Any Ideas?
As Carl said, if access to your content requires a log in, then there isn't a whole lot you can do.
However, if you can separate out a "teaser" of each content page and have a link to "read more" from those pages that requires a login, then you'll be good to go.
The teaser page should have enough searchable text that google will be able to successfully include it in search results.
There are a number of sites that do just this. You search for something, click on the link to go to their site. Once there you can see maybe two paragraphs worth of information. If you want more a link takes you to a login / register page.
Okey I found a not elegant solution, but it suits my needs:
http://forums.asp.net/t/1358997.aspx
""For now, I found a workaround: I capture the End-request event and see if the status code is "302 redirected"; if it is, I'll just alter the address from there and do whatever I need to do. Not the most elegant solution (and requires more processing for every page request; not just login redirects), but at least it works.""
I wanna implement url rewriting so that, for example, all german pages have a url with /de/ after the domain name (and english pages with an /en/) but I don't actually have to create and manage all those subdirectories. I want this "de"/en to persist through out the website
Just like mentioned in the article below:-
http://www.deevelop.com/en/web-design-company/blog/12/Multilingual-website.html
Please check the content under "SUBDIRECTORIES" heading in this article.
This article doesn't explain stuff in detail. Can I please have link to more such examples that are elaborative enough?
Or if someone has implemented such a thing may help. Thanks
URL rewriting is the process of intercepting an incoming Web request and redirecting the request to a different resource. When performing URL rewriting, typically the URL being requested is checked and, based on its value, the request is redirected to a different URL. For example, in the case where a website restructuring caused all of the Web pages in the /people/ directory to be moved to a /info/employees/ directory, you would want to use URL rewriting to check if a Web request was intended for a file in the /people/ directory. If the request was for a file in the /people/ directory, you'd want to automatically redirect the request to the same file, but in the /info/employees/ directory instead.
You first need to download SP1(free) and install it, then follow these links:
http://msdn.microsoft.com/en-us/magazine/2009.01.extremeaspnet.aspx
http://chriscavanagh.wordpress.com/2008/03/11/aspnet-routing-goodbye-url-rewriting/