How to make multiple url redirection using global.asax in IIS 6?
-
sir,
I am working with IIS 6 site and i ant to redirect three different urls of a domain to one url, i.e, there are the different versions of the same url...so how can i create one? I have found a script on google. but it says redirecting one url. see it here:
Sub Application_BeginRequest(ByVal sender as Object, ByVal e as EventArgs) Try Dim requestedDomain As String = HttpContext.Current.Request.Url.ToString().toLower() If InStr(requestedDomain, "http://yoursite.com") Then requestedDomain = requestedDomain.Replace("http://yoursite.com", "http://www.yoursite.com") Response.Clear() Response.Status = "301 Moved Permanently" Response.AddHeader("Location", requestedDomain) Response.End() End If Catch ex As Exception Response.Write("Error in Global.asax :" & ex.Message) End Try End Sub
-
I'd recommend implementing 301 at the server level e.g. in IIS settings rather than the code level.
There are loads of guides on this - just search for "301 iis6 redirect" on your favourite search engine.
Hope this helps.
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
Should I use a canonical URL for images uploaded to a blog post in Wordpress?
Hi, I have a wordpress website that has articles/news posts witch contain imagery. I've noticed that in the Media Library, when you upload an image to a blog post it generates a new permalink ...article-name/article-image-01.jpg I have Yoast SEO plugin and have the option to set a canonical URL for this image. Should I point it back to the actual article? Thanks for any helpers with this.
Technical SEO | | Easigrass0 -
URL Structure & SEO - Should we be using sub-folders?
Hi all, As part of our content marketing efforts we have run a number of initiatives in the past and created pages on the website to go along with them (also where the links for these particular projects point to). However, the URL structure isn't actually a reflection of where the pages sit on the site. Unfortunately I'm unable to provide a URL for reasons I won't bore you with, but here's an example: We recently ran a competition that was very successful in generating links. The URL for this is www.domain.co.uk/competition. However, the page actually sits within the About Us section - which is where all of our news and content marketing pages go - and uses a URL override. How much of an issue is this in regards to A) Our SEO in general?; and B) Ensuring we receive as much equity from the links we earn as possible? A brief explanation of what URL overrides actually are would also be useful! (We have a digital marketing agency who handle most of our SEO) Thanks in advance guys! John
Technical SEO | | NAHL-14300 -
International SEO: What to do when you're using a ccTLD and want to go global
I'm hoping someone in the Moz community can help me with this one! Essentially, we have a .co.uk brand which wants to have more of an international presence. My question is, purely based on the fact that we're a .co.uk, will we find it more challenging to develop a search engine presence in European/BRIC markets? In a perfect world, we'd have a .com/country or a .es/ etc, but if this isn't possible, how hindered are we if we stick with the .co.uk and want to build a presence in Spain?
Technical SEO | | ecommercebc0 -
To 301 redirect or not...
Hi guys i'd like to get your opinion on this. We currently have two sites, site A is the old one with PA44 and DA33. Site B is the new one which is going to replace site A it currently has PA37 and DA24 Our plan for the future is to shut down site A and redirect all pages using 301 to the relevant pages on side B. Currently we have some links in place for a couple of keywords on site A to site B which seems to be working great for our ranking. Now i'm wondering if this is maybe a good option, to give back links from A to B or will i pass through more link juice when redirecting everything? (ps. both are e commerce sites hosted and registred with different companies)
Technical SEO | | Immanuel0 -
What if I point my canonicals to a URL version that is not used in internal links
My web developer has pointed the "good" URLs that I use in my internal link structure (top-nav/footer) to another duplicate version of my pages. Now the URLs that receive all the canonical link value are not the ones I use on my website. is this a problem and why??? In theory the implementation is good because both have equal content. But does it harm my link equity if it directs to a URL which is not included in my internal link architecture.
Technical SEO | | DeptAgency0 -
What's the best URL Structure if my company is in multiple locations or cities?
I have read numerous intelligent, well informed responses to this question but have yet to hear a definitive answer from an authority. Here's the situation. Let's say I have a company who's URL is www.awesomecompany.com who provides one service called 'Awesome Service' This company has 20 franchises in the 20 largest US cities. They want a uniform online presence, meaning they want their design to remain consistent across all 20 domains. My question is this; what's the best domain or url structure for these 20 sites? Subdomain - dallas.awesomecompany.co Unique URL - www.dallasawesomecompany.com Directory - www.awesomecompany.com/dallas/ Here's my thoughts on this question but I'm really hoping someone b*tch slaps me and tells me I'm wrong: Of these three potential solutions these are how I would rank them and why: Subdomains Pros: Allows me to build an entire site so if my local site grows to 50+ pages, it's still easy to navigate Allows me to brand root domain and leverage brand trust of root domain (let's say the franchise is starbucks.com for instance) Cons: This subdomain is basically a brand new url in google's eyes and any link building will not benefit root domain. Directory Pros Fully leverages the root domain branding and fully allows for further branding If the domain is an authority site, ranking for sub pages will be achieved much quicker Cons While this is a great solution if you just want a simple map listing and contact info page for each of your 20 locations, what if each location want's their own "about us" page and their own "Awesome Service" page optimized for their respective City (i.e. Awesome Service in Dallas)? The Navigation and potentially the URL is going to start to get really confusing and cumbersome for the end user. Think about it, which is preferable?: dallas.awesomcompany.com/awesome-service/ www.awesomecompany.com/dallas/awesome-service (especially when www.awesomecompany.com/awesome-service/ already exists Unique URL Pros Potentially quicker rankings achieved than a subdomain if it's an exact match domain name (i.e. dallasawesomeservice.com) Cons Does not leverage the www.awesomecompany.com brand Could look like an imposter It is literally a brand new domain in Google's eyes so all SEO efforts would start from scratch Obviously what goes without saying is that all of these domains would need to have unique content on them to avoid duplicate content penalties. I'm very curious to hear what you all have to say.
Technical SEO | | BrianJGomez0 -
Regarding Canonical Url
We have a e-commerce website. Our own homegrown:-) We recently visited Google Webmaster tools and could see that Google mention we have double Meta tags for some main and subcategories. Each Product Category on our site have a subcategory/ Sub url - "Bestseller", "On Sale", "just arrived". The sub url is not a really a real category and we can therefore not make totally unique description and title for does urls. domain.com/category domain.com/category/bestseller
Technical SEO | | areygie
domain.com/category/on-sale
domain.com/category/just-arrived We are thinking about 2 solutions. 1. Canonical Url on subcategory pointing to main category.
2. Or add a word bestseller, on sale or just arrived in front of the meta title/description. We can do this from code. I personally opt for option 1. But I am little unsure what is the best way to go. Thanks in advance for your advice0 -
Link Juice passing through a redirect of a disallowed URL
Hey guys! Suppose I disallow search bots from indexing anything on my secure server in my robots.txt, and 301 redirect all of my secure server traffic to my non-secure site. Will the search bots see the redirect before they realize that they're disallowed from accessing that page? Or will they see that page is disallowed and not follow the redirect? Should I change my robots.txt to allow search bots to crawl my secure site so they can find the redirects?
Technical SEO | | john4math0