Skip to main content

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.

Filter by
Sorted by
Tagged with
316 votes
5 answers
740k views

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; ...
jeffreyveon's user avatar
  • 3,325
285 votes
5 answers
117k views

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 ...
Kyle Brandt's user avatar
  • 84.6k
86 votes
2 answers
218k views

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 ...
userSteve's user avatar
  • 1,633
45 votes
6 answers
24k views

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 ...
Robert Petz's user avatar
23 votes
2 answers
8k views

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 ...
ucker's user avatar
  • 245
19 votes
10 answers
92k views

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 ...
Ivan's user avatar
  • 893
17 votes
4 answers
53k views

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 ...
Jeff's user avatar
  • 323
16 votes
3 answers
66k views

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 ...
Denis Rendler's user avatar
13 votes
1 answer
22k views

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 ...
Geo C.'s user avatar
  • 233
11 votes
1 answer
19k views

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 ...
ranieri's user avatar
  • 233
11 votes
1 answer
6k views

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 ...
elle's user avatar
  • 123
11 votes
2 answers
27k views

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 ...
Suzan Cioc's user avatar
7 votes
3 answers
11k views

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 ...
anonymous-one's user avatar
7 votes
3 answers
16k views

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/...
Kendall Hopkins's user avatar
7 votes
1 answer
53k views

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 ...
Dark Star1's user avatar
  • 1,445
6 votes
5 answers
10k views

Modify Nginx 301 response body

So, when doing curl -i http://example.com on my server, I get this response in body: <html> <head><title>301 Moved Permanently</title></head> <body bgcolor="white">...
Lars's user avatar
  • 163
6 votes
1 answer
5k views

nginx 301'ing limit_req rate limited requests instead of error page

I have a bulk search form on apache servers behind nginx. I'd like to protect that location so that the second request in a 10 minute period gets 301'd to a "Would you like to use our API" page ...
mogmismo's user avatar
6 votes
1 answer
4k views

Best way to do a 301 redirect from non-www to www. in IIS7.5?

What's the best way to do a 301 redirect from non-www 'somedomain.com' to 'www.somedomain.com' in IIS7.5? Thank you
UpTheCreek's user avatar
  • 1,638
6 votes
4 answers
8k views

IIS 301 Redirect from "/index.html" to "/" for SEO Canonicalization

I used the technique explained here for IIS (http://www.webconfs.com/how-to-redirect-a-webpage.php), but this appears to result in an infinite loop when applied to "/index.htm" and redirected to "/". ...
user avatar
6 votes
2 answers
16k views

Nginx still redirects even though I removed the rule from the conf

I was using this block for redirecting the website's IP to the actual URL: # IP to domain redirect server { # tell on which port this server listens listen [::]:80; listen 80; ...
Vila's user avatar
  • 169
5 votes
3 answers
23k views

How to configure nginx to redirect all request from domain aliases to main domain?

I do have an nginx server which responds to several domains and I do want to redirect all request to the main domain. Example: website responding for xxx xxx.example.com yyy.example.com $hostname for ...
sorin's user avatar
  • 8,266
5 votes
3 answers
872 views

The 301 'www' nightmare. How do I change back?

About six months ago, I decided it would be best to put my website on the naked domain, let's just say 'example.com'. I did what all the instructions websites have told me with adding a 301 redirect ...
Anthony's user avatar
  • 51
5 votes
3 answers
2k views

CNAME versus an additional A&AAAA record

So, let us say that we have set-up an A record and an AAAA record for @, and for www we have set-up a CNAME pointing to @. When a new visitor visits example.com and the webserver sends a 301 ...
Xen's user avatar
  • 468
5 votes
4 answers
6k views

Nginx: Redirect both http and https root to subdirectory

I'm attempting to redirect the root domain for both http and https in nginx to the same subdirectory (https): So e.g. http://example.com -> https://example.com/subdirectory https://example.com -&...
Elijah Paul's user avatar
5 votes
4 answers
20k views

How to redirect non-www to www without hardcoding using .htaccess?

RewriteEngine On RewriteCond %{HTTPS} !=on RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L] ...causes a perfect, non-hardcoding 301 redirect from "www to non-www", ...
user avatar
5 votes
1 answer
2k views

Mass 301 redirect URLs with Nginx

I have a list of 600 urls. Due to a change in the system the urls will change to a new format. I will have a list with the old urls and corresponding new ones. But how do i 301 redirect all of them? ...
Jim's user avatar
  • 410
4 votes
4 answers
13k views

How can I redirect domain A to domain B without hosting, using only DNS records?

I want to redirect domain A (without hosting space) to domain B (301), but when I try https://domainA.com or https://www.domainA.com it ends with ERR_CONNECTION_REFUSED. Is it even possible to use ...
Patryk Chowratowicz 'Zszywacz''s user avatar
4 votes
5 answers
9k views

How to redirect https://domain.com to https://www.domain.com using IIS?

I have a 301 set up which redirects http://domain.com to http://www.domain.com (http://www.domain.com$S$Q) but if I browse to https://domain.com I get an SSL error (as it expects www.domain.com). Is ...
Mr. Flibble's user avatar
4 votes
1 answer
977 views

nginx - which way is better to redirect and why

I want to redirect from www.mydomain.com to domain.com in nginx. I search the internet and found two ways: First way server { listen 80; server_name www.domain.com; ...
Christos Baziotis's user avatar
4 votes
1 answer
671 views

Should I use HTTP code 301 or 426 on port 80 of a HTTPS only server?

When a user hits my SSL/TLS only server at port 80, should I advertise Upgrade Required (426) or redirect with Moved Permanently (301)? What are the drawbacks and benefits of each approach? As far ...
psilva's user avatar
  • 143
4 votes
1 answer
4k views

Have nginx redirect everything to https except one directory

I need nginx to redirect all http URLs to https, with the exception a ".secret/" directory which should continue to be served as http. So, for example: http://example.com/a.html --> ...
scaramouche's user avatar
4 votes
1 answer
18k views

How to permanently redirect port 8080 URL to port 80 using nginx

Because of my carelessness, I put http://www.domain.com:8080/xxx/index.html on the internet. I don't want to lose that traffic, so i want to permanent redirect that url to http://www.domain.com/xxx/...
user avatar
4 votes
1 answer
3k views

Nginx redirecting domain to port 8000 with a 301

I have been looking everywhere to figure out why my nginx server is causing a 301 redirect on one domain, and not the other. I have two sites configured on this server in an apache style (sites-...
David Allen's user avatar
4 votes
1 answer
5k views

nginx return 301 / redirect

among all 'redirect in nginx' questions I couldn't find how to redirect (using return 301 and better no ifs) using regexps. I have a link to my website and I'd like to remove parameter a the end: ...
ppp's user avatar
  • 41
4 votes
1 answer
4k views

Apache Redirect Permanent Not Working

I have two redirects on my site. One of them is working, and one of them is not. Here are the relevant lines from my configuration, edited to protect the innocent. <VirtualHost *:80> ServerName ...
ctlacko's user avatar
  • 141
3 votes
3 answers
14k views

SSL certificate error in domain redirection

I am managing two domain names and want to redirect one to the other. I set up a domain forwarding with 301 permanent redirection from domain S (source) to domain T (target). The server on domain T ...
emonigma's user avatar
  • 269
3 votes
4 answers
4k views

nginx downloads empty file when requested on port 80 (instead of redirecting to port 443)

my nginx webserver does not do, what he should. All http:// requests to the server should be redirected with http 301 to https://, it worked fine for the last few days, until it stopped working ...
Unkn0wn0x's user avatar
3 votes
1 answer
5k views

302 redirect loop with nginx and Wordpress

I've been searching a couple of hours in Serverfault trying to solve this problem but I can not find a solution. What happens is: I am having a 302 redirect loop using wget in my site, but not using ...
Alejandro Alcalde's user avatar
3 votes
1 answer
18k views

Apache - httpd.conf redirect with X-Forward-For - Not working?

I'm having an a-hole of a problem redirecting traffic. Basically, I'm building a new web server and it's on another version of my domain, so I want to redirect traffic not from this IP. Problem is ...
waxical's user avatar
  • 334
3 votes
1 answer
9k views

NGINX: strip querystring in rewrite

I'd like to make a 301 rewrite to the sites's index without any querystring. Like this: http://example.com/anypage.asp?anyvar=anyvalue To: http://example.com/ Here's a real example: http://...
Roger's user avatar
  • 473
3 votes
1 answer
9k views

Using Apache RedirectPermanent to send all requests to a specific subfolder

Having asked a long and convoluted question earlier, I now have some code here using RedirectPermanent that I need help with. We're merging an old site into the new one, and don't care about mapping ...
GDP's user avatar
  • 135
3 votes
3 answers
1k views

Redirecting from https to http?

Strange problem here. I use FullCalendar to initiate an ajax request to an endpoint on my server. Endpoint is: https://my_website/events/?start=2019-03-31&end=2019-05-12&_=1555698739056 ...
Willard Solutions's user avatar
3 votes
1 answer
152 views

What is the correct way to move an rss feed? Is there a temporary workaround for google reader users?

I run a website that has published its RSS feed at a given location for years. However, I'm now forced to move the feed to another URL. Let's say the original URL was www.example.com/rss.xml and the ...
Dafydd Rees's user avatar
3 votes
2 answers
31k views

How to redirect example.com from HTTPS to HTTP, then HTTP example.com to newdomain.com?

As of now I use this rule (in .htaccess of example.com) to redirect HTTPS/HTTP example.com to newdomain.com: Options +FollowSymLinks RewriteEngine on RewriteRule (.*) http://newdomain.com/$1 [R=301,L]...
user avatar
3 votes
1 answer
2k views

Conditional 301 redirect depending on server (localhost vs production)

By practise I do a 301 redirect non-www -> www for my production server deployments. But I have a little annoying problem/discrepency with the .htaccess rewrite settings between my development server ...
Prembo's user avatar
  • 937
3 votes
1 answer
790 views

Redirect all URLs from http to https (with 301 ) except for a few [duplicate]

I am trying to 301 redirect all URLs from http:// to https://, using .htaccess. Some dynamically generated URLs should be excluded. Example of some URLs I do not want to redirect: example.com/tt....
Rogge's user avatar
  • 33
3 votes
1 answer
5k views

How to respond to http health check at a particular url while redirecting other traffics?

Background: I am trying to set up an instance group in Google cloud platform. The instance group consists a number of nginx instances whose job is simply to redirect incoming https traffic to an ...
Anthony Kong's user avatar
  • 3,518
3 votes
1 answer
66 views

Apache htaccess redirect?

I have a client who has a domain like this-site.com and also thissite.com Without going into the entire issue behind it, we need to redirect any incoming request to any *.this-site.com to the matching ...
Matt Morrow's user avatar
3 votes
1 answer
4k views

How can Nginx force browsers to disable or flush the redirect cache?

We have the following secure site. If the user opens http://name.tld, he should be redirected to https://name.tld. We initially messed up the order of the domains in the secure site, so http://name....
mitchkman's user avatar
  • 159
3 votes
1 answer
468 views

Cannot renew Public IP address SSL certificate. Any alternatives?

From what I've read and researched (here, other places) I'm almost certain what I'm asking will not be possible but any alternative suggestions are welcome. I have a server with a Public IP address ...
PadraigD's user avatar
  • 141

1
2 3 4 5
11