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
264
votes
5answers
97k 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 ...
149
votes
5answers
296k 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; ...
24
votes
4answers
7k 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 ...
23
votes
2answers
45k 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 ...
20
votes
2answers
6k 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 ...
13
votes
3answers
39k 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 ...
13
votes
9answers
43k 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 ...
10
votes
4answers
21k 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 ...
10
votes
1answer
13k 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 ...
10
votes
1answer
4k 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 ...
9
votes
2answers
13k 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 ...
7
votes
3answers
9k 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/...
6
votes
3answers
6k 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 ...
6
votes
1answer
8k 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 ...
6
votes
1answer
38k 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 ...
6
votes
1answer
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
6
votes
4answers
6k 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 "/". ...
5
votes
3answers
15k 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 ...
5
votes
1answer
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? ...
4
votes
3answers
618 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 ...
4
votes
3answers
1k 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 ...
4
votes
1answer
561 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 ...
4
votes
5answers
5k 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 ...
4
votes
1answer
719 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; ...
4
votes
4answers
14k 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", ...
4
votes
1answer
2k 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 ...
4
votes
1answer
4k 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: ...
4
votes
1answer
3k 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 ...
3
votes
1answer
7k 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://...
3
votes
1answer
3k 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 ...
3
votes
4answers
887 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 ...
3
votes
1answer
13k 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 ...
3
votes
1answer
15k 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/...
3
votes
1answer
82 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 ...
3
votes
3answers
243 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 ...
3
votes
2answers
29k 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]...
3
votes
1answer
1k 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 ...
3
votes
1answer
62 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....
3
votes
1answer
54 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 ...
3
votes
1answer
244 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 ...
3
votes
1answer
2k 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-...
3
votes
1answer
5k views

301 redirect Rule For Load Balance F5 BigIp

I have a load balancer F5 Big ip for my website. Currently, I am having 302 redirect in place; however, I wanted to apply 301 but dont know how. For example: My website (abc.com) when typed 302 ...
3
votes
1answer
2k 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....
3
votes
0answers
50 views

301 Redirect to other domain of selected deep pages only?

would appreciate help on this i am trying to 301 selected deep pages only from one domain to deep pages on another domain. I do not wish to 301 the entire site. My questions are a) is this possible ...
3
votes
0answers
62 views

Redirect user to an arbitrary application protocol (used by Android app)

I have an Android application that declares an intent using a in-house protocol. You can launch it by opening a webpage that contains a link to : myapplication://foo-bar I want to an URL on my ...
3
votes
2answers
141 views

Redirect to https:// with www apache2

I am redirecting all http:// request to https:// using apache2 host .conf file like this. <VirtualHost *:80> ServerName example.com ServerAlias www.example.com Redirect / https://...
3
votes
0answers
580 views

nginx redirects requests from apache proxy to real server address

Description: [server 1] <-|-> [server 2] [Apache] <-|-> [nginx <--> gunicorn <--> django] Apache is running on a server 1 which silently redirects just one subdomain to ...
3
votes
1answer
245 views

Need some help on optimizing 301 redirects in nginx

I just created a new structure for a website, and I need some help on redirecting to new places. The code that works is here, but I guess this can be optimized a lot. location = /nl { rewrite ^ ...
2
votes
2answers
4k views

Redirect loop when forcing SSL on Nginx server

Lately I have been trying to redirect to HTTPS using Nginx but I keep getting a redirect loop after I try to visit my site in a browser. Here is my full server block config file: server { listen ...
2
votes
3answers
1k views

Can I make Apache ErrorDocument return 404 instead of 301?

In my .htaccess I have ErrorDocument 404 http://foo.com/404.html It works, in the sense that I recover from any file not found error and show the 404 page instead, but the way it works is to ...