Questions tagged [redirect]

HTTP or HTML mechanisms used for redirecting browsers to where the actual content is located

Tag for questions related to issues with configuration of redirects in HTTP servers, problems they may cause or solve.

Redirections are used to redirect user traffic to new location of content, as a way to handle errors or for load balancing.

They are usually implemented with HTTP redirects have status code beginning with 3. Examples include:

301 Moved permanently
302 Found (past "Moved temporarily")
2294 questions
552
votes
11 answers

In Nginx, how can I rewrite all http requests to https while maintaining sub-domain?

I want to rewrite all http requests on my web server to be https requests, I started with the following: server { listen 80; location / { rewrite ^(.*) https://mysite.com$1 permanent; } ... One Problem is that this…
MikeN
  • 8,442
  • 5
  • 23
  • 18
284
votes
5 answers

Redirect, Change URLs or Redirect HTTP to HTTPS in Apache - Everything You Ever Wanted to Know About mod_rewrite Rules but Were Afraid to Ask

This is a Canonical Question about Apache's mod_rewrite. Changing a request URL or redirecting users to a different URL than the one they originally requested is done using mod_rewrite. This includes such things as: Changing HTTP to HTTPS (or the…
Kyle Brandt
  • 83,619
  • 74
  • 305
  • 448
258
votes
7 answers

What’s the point in having “www” in a URL?

Other than for historical reasons, is there is reason to have “www” in a URL? Should I create a permanent redirect from www.xyz.com to xyz.com, or from xyz.com to www.xyz.com? Which one would you suggest and why?
Quintin Par
  • 4,373
  • 11
  • 49
  • 72
238
votes
7 answers

How to force or redirect to SSL in nginx?

I have a signup page on a subdomain like: https://signup.example.com It should only be accessible via HTTPS but I'm worried people might somehow stumble upon it via HTTP and get a 404. My html/server block in nginx looks like this: html { server…
Callmeed
  • 2,725
  • 4
  • 20
  • 15
89
votes
4 answers

Nginx Redirect via Proxy, Rewrite and Preserve URL

In Nginx we have been trying to redirect a URL as follows: http://example.com/some/path -> http://192.168.1.24 where the user still sees the original URL in their browser. Once the user is redirected, say they click on the link to…
robjohncox
  • 1,045
  • 1
  • 8
  • 7
85
votes
2 answers

Best way to redirect all HTTP to HTTPS in IIS

We want ALL sites on our webserver (IIS 10) to enforce SSL (ie redirect HTTP to HTTPS). We are currently 'Requiring SSL' on each site and setting up a 403 error handler to perform a 302 redirect to the https address for that specific site. This…
userSteve
  • 1,573
  • 4
  • 23
  • 33
82
votes
4 answers

How to get Apache2 to redirect to a subdirectory

I am running apache2 on Debian etch, with multiple virtual hosts. I want to redirect so that http://git.example.com goes to http://git.example.com/git/ Should be really simple, but Google isn't quite cutting it. I've tried the Redirect and Rewrite…
Hamish Downer
  • 9,420
  • 6
  • 38
  • 51
71
votes
4 answers

Redirect URL within Apache VirtualHost?

I have a dedicated server with Apache, on which I've set up some VirtualHosts. I've set up one to handle the www domain as well as the non-www domain. My VH .conf file for the www: DocumentRoot /var/www/site ServerName…
DisgruntledGoat
  • 2,629
  • 4
  • 28
  • 36
60
votes
4 answers

How to redirect root and only root via htaccess?

I want to redirect only my root to another url, but maintain all the /sub/directories where they belong (and redirect) example: mysite.com/1 redirects to somewhere mysite.com/admin opens a page i want mysite.com/ to redirect to mysecondsite.com and…
jardel
57
votes
10 answers

How to use DNS/Hostnames or Other ways to resolve to a specific IP:Port

This is a Canonical Question about DNS/Hostnames resolution to IPs/Ports Example 1 I'm running a web server on port 80 and another on port 87. I would like to use DNS so that www.example.com goes to port 87. How can I accomplish this using DNS…
Tom Smykowski
  • 1,125
  • 5
  • 19
  • 27
54
votes
1 answer

Capturing STDERR and STDOUT to file using tee

I'm unclear what the best order is to capture both STDERR and STDOUT to the same file using tee. I know that if I want to pipe to a file I have to map the filehandle after the redirect, i.e. find . >/tmp/output.txt 2>&1 This instructs the shell to…
PP.
  • 3,316
  • 6
  • 27
  • 31
41
votes
3 answers

Simple apache2 redirect from one domain to another

What I want to do is the following: My domain xy.example.com no longer exists. Thus I want to do a simple redirect to the new domain abc.example.com. It should be a redirect, that also works when someone types in the browser bar…
JohnnyFromBF
  • 1,259
  • 6
  • 21
  • 25
39
votes
3 answers

Nginx - How to redirect users with certain IP to special page

I run quite a big image gallery and there are 5 visitors that create an enormous amount of traffic by downloading the whole site every day using webcopiers. Those visitors have static IPs as it seems. What I would like to achieve is that those 5 IPs…
Alex
  • 391
  • 1
  • 3
  • 6
37
votes
7 answers

How do I redirect www to non-www in Route53?

I host my site at domain.com. My DNS entries in Route53 are as follows: domain.com A xxx.xxx.xxx.xxx 300 domain.com NS stuff.awsdns-47.org 172800 domain.com SOA stuff.awsdns-47.org 900 I would like to redirect…
fredley
  • 575
  • 1
  • 5
  • 14
36
votes
3 answers

Examples of 302 vs 303

What is the difference between a 302 and 303 response? http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html 10.3.3 302 Found 10.3.4 303 See Other Are these interchangeable or why would one be used over the other? Could you please provide a use…
David542
  • 939
  • 3
  • 10
  • 15
1
2 3
99 100