http-status-code-301

How to 301 redirect in ASP.NET 4.0?

我们两清 提交于 2019-11-29 03:50:57
I am trying to implement URL redirect for the website rather than doing it page by page. I want to do it in the global.asax file. Below is the code i have defined. I want to have http://website.net as my main url & want to have a permanent URL redirect if someone types in http://www.website.net . Unfortunately it is not working for the live website. Can anyone point out the problem in the code. The code doesn't generate any error. void Application_Start(object sender, EventArgs e) { // Code that runs on application startup if (HttpContext.Current.Request.Url.ToString().ToLower().Contains("http

Global 301 redirection from domain to www.domain

梦想与她 提交于 2019-11-29 02:26:18
could i use the begin request of Global.asax to redirect everything, from mydomain.domain to www.mydomain.domain ? If this one is true, how can i do that? protected void Application_PreRequestHandlerExecute(Object sender, EventArgs e) { string currentUrl = HttpContext.Current.Request.Path.ToLower(); if(currentUrl.StartsWith("http://mydomain")) { Response.Status = "301 Moved Permanently"; Response.AddHeader("Location", currentUrl.Replace("http://mydomain", "http://www.mydomain")); Response.End(); } } A couple of minor changes to Jan's answer got it working for me: protected void Application

URL redirection in Java return 302 instead of 301

耗尽温柔 提交于 2019-11-29 01:50:36
问题 I'm using this code to redirect url: response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY); response.sendRedirect(newURL); what I can see is a correct redirection but the value returned in the response is 302 instead of 301. How can I force it to 301? 回答1: If you use sendRedirect , it will reset the status to 302. You'll have to use setHeader to set the Location header yourself to redirect using a 301 status. Example code: response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);

Does 301 redirect always preserve referrer?

╄→гoц情女王★ 提交于 2019-11-29 01:05:53
I want to know whether 301 redirect always preserve referrer. I make a page called "gotoorig_https.html" which contains a hyperlink to a page "orig_https.asp". "orig_https.asp" will 301 redirect to "dest.html" which shows the document.referrer. In this case, http page(gotoorig_https.html) -> orig_https.asp(301 redirect)-> https page (dest.html) <--the referrer preserves https page(gotoorig_https.html) -> orig_https.asp(301 redirect)-> https page (dest.html) <--the referrer preserves I also make a page called "gotoorig_http.html" which contains a hyperlink to a page "orig_http.asp". "orig_http

htaccess multi language site with sub directories, and default 301

﹥>﹥吖頭↗ 提交于 2019-11-28 23:30:38
I am having some issues setting up my htaccess to allow multiple languages utilising the sub directory method eg: http://www.domain.com/en/ http://www.domain.com/sw/ http://www.domain.com/ie/ Also to complicate things, the project isn't currently live, its on a dev server. For example, I am currently accessing the project at: http://dev.domain.com/devname/projectname/ And I want the above to automatically 301 redirect to: http://dev.domain.com/devname/projectname/en/ Here is my htaccess: Options +FollowSymLinks -MultiViews RewriteEngine on # ----------------------------------------------------

StackOverflow like URL Routing

别说谁变了你拦得住时间么 提交于 2019-11-28 21:36:21
Its my understanding that the questions in StackOverflow has the following format http://stackoverflow.com/questions/{question-id}/{slug-made-from-question-title} So basically the question is retrieved using the question-id. so whatever value I give the slug is immaterial. First I would like to know whether this understanding is wrong :) I have a URL http://stackoverflow.com/questions/6291678/convert-input-string-to-a-clean-readable-and-browser-acceptable-route-data Then I changed the slug manually like this. http://stackoverflow.com/questions/6291678/naveen But it changed to the original slug

Redirect multiple domains to one domain (with or without www before)

旧巷老猫 提交于 2019-11-28 18:22:26
I have about 18 domains that need to be redirected to a new one. It has to work both with or without www prepended. I've tried this: <IfModule mod_rewrite.c> RewriteEngine on Rewritecond %{HTTP_HOST} !^www\.domain\.com RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L] </IfModule> That gives me a redirect loop (and only works with www before, i think?). RewriteEngine on RewriteCond %{HTTP_HOST} ^domain1.com [OR] RewriteCond %{HTTP_HOST} ^domain2.com [OR] RewriteCond %{HTTP_HOST} ^domain3.com [OR] RewriteCond %{HTTP_HOST} ^domain4.com [OR] RewriteCond %{HTTP_HOST} ^domain5.com RewriteRule ^(

What is the best approach for redirection of old pages in Jekyll and GitHub Pages?

回眸只為那壹抹淺笑 提交于 2019-11-28 15:22:46
I have blog on github pages - jekyll What is the best way to solve url strategy migration? I found the best practice in common is create htaccess like so Redirect 301 /programovani/2010/04/git-co-to-je-a-co-s-tim/ /2010/04/05/git-co-to-je-a-co-s-tim.html But it does not seems to work with Github. Another solution i found is create rake task, which will generate redirection pages. But since it's an html, it's not able to send 301 head, so SE crawlers will not recognize it as an redirection. Konrad Podgórski The best solution is to use both <meta http-equiv="refresh" and <link rel="canonical"

How do I programatically 301 redirect in an asp page?

我只是一个虾纸丫 提交于 2019-11-28 12:59:42
I'm upgrading some classic asp pages to .net, but not all of them. Rather than go and modify all the links in this backwards system, which pulls some of its links from a cms data store. I would like to take advantage of http and just remove the code our of that file, and perform a programatic 301 so that all the other pages can just be upgraded piecemeal. Mehrdad Afshari Response.Buffer = true Response.Status = "301 Redirect" Response.AddHeader "Location", "redirection-url-goes-here" Response.End 来源: https://stackoverflow.com/questions/868851/how-do-i-programatically-301-redirect-in-an-asp

How to identify if referrer is a 301 redirect

可紊 提交于 2019-11-28 11:25:23
问题 I'm implementing a slug system for my website at the moment. I plan to redirect invalid slugs to the correct on that is stored in the database. E.g. http://example.com/11/wrong-slug Hit db, check if 11's slug is wrong-slug if not do 301 redirect http://example.com/11/right-slug Detect 301 and inform user that they followed an invalid link Is it possible to identify the 301 redirect preferably using PHP so I can ask the user to update there bookmark etc. Thanks, Jamie. 回答1: Several solutions