Questions tagged [301-redirect]

The HTTP response status code 301 Moved Permanently is used for permanent redirection. This status code should be used with the location header.

  • If a client has link-editing capabilities, it should update all references to the Request URI. The response is cachable
  • Unless the request method was HEAD, the entity should contain a small hypertext note with a hyperlink to the new URI(s).
  • If the 301 status code is received in response to a request of any type other than GET or HEAD, the client must ask the user before redirecting.

More info in RFC 2616

533 questions
308
votes
5 answers

Nginx reverse proxy + URL rewrite

Nginx is running on port 80, and I'm using it to reverse proxy URLs with path /foo to port 3200 this way: location /foo { proxy_pass http://localhost:3200; proxy_redirect off; proxy_set_header …
jeffreyveon
  • 3,245
  • 3
  • 15
  • 7
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
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
42
votes
6 answers

View the SSL certificate of a page that immediately redirects to another

So I've googled quite a bit for this but it appears that my google-fu fails me - apologies if this is a trivial and already answered question, I could not find anything about this I'm trying to diagnose an SSL certificate hostname mismatch. When I…
Robert Petz
  • 545
  • 1
  • 5
  • 9
23
votes
2 answers

Apache: What is the best way to handle thousands of permanent redirects?

We've a list of 3000 301 redirects. We need assistance on What would the best place to put these? It seems putting these 3000 lines inside vhost in httpd.conf would be a mess. What are recommended ways to handle thousands of urls? How much is it…
ucker
  • 245
  • 2
  • 5
19
votes
10 answers

Restrict direct IP access to website

I want to restrict direct IP access to my website. I found several solutions involving .htaccess but none work. I've also found one solution via apache virtual hosts config which was working fine up until I installed a SSL certificate through…
Ivan
  • 893
  • 2
  • 9
  • 23
17
votes
4 answers

Is an SSL Cert needed for redirects?

We currently have a website set to redirect to a new address (our client changed domain names, but wants the old domain to send people to the new site) in IIS 8.5 using permanant redirects found in the 'HTTP Redirect' feature for the site. The SSL…
Jeff
  • 323
  • 2
  • 3
  • 8
16
votes
3 answers

Apache 2.4 restrict URL to certain IPs

I am trying to restrict a specific URL to be available outside the network only to specific IP addresses. When a user outside tries to access that URL and not from the list of IPs he should be redirected to the homepage. This is what I've tried so…
Denis Rendler
  • 163
  • 1
  • 1
  • 7
12
votes
1 answer

How to stop nginx 301 auto redirect when trailing slash is not in URI?

Every time I try foobar.com/test in browser, nginx seems to redirect (301) the client to foobar.com/test/. This behaviour is unacceptable. The proxied server is a remote Apache web server. I have tried direct calls to the Apache server (without a…
Geo C.
  • 223
  • 1
  • 2
  • 5
11
votes
1 answer

Nginx redirect all old domain subdomains to new one

I had a very long domain, so I decided to change it to a shorter and more friendly one. But since I have a lot of subdomains (in fact, I have a subdomain wildcard), I wanted to keep the subdomain while changing only the domain part. So, I made the…
ranieri
  • 233
  • 1
  • 2
  • 9
11
votes
1 answer

Empty/Null Apache request entries in access log

This entry got logged in a Apache access log: IP ADDRESS - - [00/00/0000:00:00:00 -0000] " " 301 - "-" "-" It was detected by LogWatch as a null HTTP Response and also got marked as a successful probe.. I am curious about how this request about made…
elle
  • 123
  • 1
  • 6
11
votes
2 answers

How to trace Apache 301 Moved Permanently?

I have one virtual host on my machine, which I am accessing localy. I am running apache2 under windows 7. When accessing this host, I see in Fiddler, that server redirects browser to different remote site with response 301 Moved Permanently But I…
Suzan Cioc
  • 251
  • 1
  • 5
  • 13
7
votes
1 answer

Getting "Too many redirects" error with nginx rewrite rule

I am trying to rewrite the domain url that targets my site such that all domain names are rewritten to www.example.com and have the following config: mysite block server { listen 80 default_server; listen [::]:80…
Dark Star1
  • 1,385
  • 7
  • 22
  • 37
7
votes
3 answers

Nginx reverse cache 301 redirects (permanent)

Is it possible to have Nginx cache all 301 redirect requests for proxy_pass? For example: Request #1: Client A requests /some/path -> sent to proxy_pass -> results in 301 redirect to /some/other/path -> nginx caches this response since it's a 301…
Kendall Hopkins
  • 403
  • 1
  • 5
  • 11
7
votes
3 answers

NGINX 301 and 302 serving small nginx document body. Any way to remove this behaviour?

We have noticed that when using nginx internal 301 and 302 handling, nginx will serve a small document body with the appropriate Location: ... header. Something along the lines of (in html): 301 redirect - nginx. As appropriate in the above…
anonymous-one
  • 1,018
  • 7
  • 27
  • 43
1
2 3
35 36