Questions tagged [redirect]

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

Filter by
Sorted by
Tagged with
285 votes
5 answers
116k 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.4k
57 votes
10 answers
79k views

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 ...
Tom Smykowski's user avatar
554 votes
11 answers
602k views

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 ...
MikeN's user avatar
  • 8,502
262 votes
7 answers
69k views

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 ...
Quintin Par's user avatar
  • 4,443
89 votes
4 answers
343k views

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 ...
robjohncox's user avatar
  • 1,045
237 votes
7 answers
344k views

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/...
Callmeed's user avatar
  • 2,715
39 votes
3 answers
125k views

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. ...
Alex's user avatar
  • 391
83 votes
4 answers
203k views

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 ...
Hamish Downer's user avatar
72 votes
4 answers
295k views

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: <VirtualHost *&...
DisgruntledGoat's user avatar
61 votes
4 answers
131k views

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 ...
user avatar
21 votes
2 answers
79k views

nginx rewrite for an url with parameters

I have an URL of this type: http://www.example.com/?param1=val1&param2=&param3=val3&param4=val4&param5=val5 And I want to redirect it to this one: http://www.example.com/newparam/...
David Morales's user avatar
12 votes
3 answers
51k views

Convert and redirect URL in uppercase to lowercase using .htaccess

I would like to redirect a URL with uppercase characters http://localhost/A/B to a lowercase version http://localhost/a/b using the .htaccess file. Using regex I can capture A and B but is it possible ...
tintin's user avatar
  • 445
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
86 votes
2 answers
214k 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,613
27 votes
2 answers
137k views

how do I get nginx to forward HTTP POST requests via rewrite?

My iOS app is currently accessing domain A via http POST but I would like to forward all requests to domain B. If I use the usual rewrite ^/(.*)$ http://mydomain/$1 permanent; the POST data seems ...
Jiho Kang's user avatar
  • 1,087
19 votes
2 answers
12k views

Redirect all requests to HTTPS, except for one subdirectory

I'm trying to move from self-signed certificates to Let's Encrypt certificates on my nginx webserver. Currently, I redirect all requests to http/80 to https/443, which uses a self signed certificate ...
SaAtomic's user avatar
  • 349
14 votes
3 answers
22k views

How to redirect all outgoing email from postfix to a single address for testing

I am setting up a testing server for a web based application that sends some email notifications. Sometimes testing is performed with real customer data, and for that reason I need to guarantee that ...
0x6A75616E's user avatar
14 votes
7 answers
32k views

Changing Servers - Redirect to new IP = No Downtime?

I am changing servers of my website. The IP of old server cannot be moved to the new one. To have no downtime I am planing to do the following, please someone confirm it will work: Setup the new ...
Denis Pshenov's user avatar
10 votes
2 answers
11k views

HowTo redirect HTTP to HTTPS on the same httpd?

Here is what I have got: CentOS 5.4 (32-bit) installed Apache httpd (Server version: Apache/2.2.11 (Unix)) mod_rewrite already presents Question: how to redirect simple http://site.com to https://...
mosg's user avatar
  • 235
9 votes
2 answers
46k views

nginx redirect to www.domain

I want to redirect the site ALWAYS to www.site.com. However, I am not sure as to how to get the WWW to always show up in front should say someone type in the domain without the www. EDIT: server { ...
Jake Thomas's user avatar
3 votes
3 answers
6k views

Nginx: Forward all Subdomains

My code doesn't work with second level tld's like domain.co.uk Here is my conf: # add www. if ($host ~ ^(?!www)) { rewrite ^/(.*)$ http://www.$host/$1 permanent; } # remove subdomain if (...
mgutt's user avatar
  • 522
37 votes
7 answers
79k views

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 ...
fredley's user avatar
  • 575
17 votes
5 answers
2k views

How can I enforce that my urls always start with www?

I want to ensure that users come to www.mydomain.com even if they arrive through the alias mydomain.com. This is so that I have control over cookies on subdomains, and so that Google sees one single ...
Magnar's user avatar
  • 1,047
17 votes
4 answers
52k 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
11 votes
4 answers
24k views

SSL Certificate errors in Captive Portals

Situation: Hotel guests attempting internet access via our captive portal. Problem: Google, Yahoo and now more and more sites redirecting all home pages to HTTPS so guest gets a Certificate error when ...
user avatar
8 votes
3 answers
16k views

NGINX redirect everything except letsencrypt to https

I have a simple config, redirect everything except letsencrypt requests to https, and then have my virtual hosts only on https.. Currently all my requests are redirected to https, and then a 404 for ...
Richard87's user avatar
  • 250
8 votes
7 answers
61k views

How do I make Nginx redirect all requests for files which do not exist to a single php file?

I have the following nginx vhost config: server { listen 80 default_server; access_log /path/to/site/dir/logs/access.log; error_log /path/to/site/dir/logs/error.log; root /path/to/...
Richard's user avatar
  • 856
6 votes
4 answers
6k views

Redirect all non-www subdomains to main www domain with Apache2

I have a website (domain.com) and I would like to redirect all my secondary domains (domain2.com, domain3.com) and all the subdomains of these domains (*.domain.com, *.domain2.com...) to the main ...
6 votes
2 answers
13k views

RedirectMatch and Query String

Compare these two RedirectMatch's. The first doesn't work: RedirectMatch 302 ^/redirect\.php[?]page=(.+)$ http://somewhereelse.com/$1 Versus this, which will redirect to http://somewhereelse.com/?...
pinate's user avatar
  • 207
6 votes
6 answers
19k views

Redirect specific e-mail address sent to a user, to another user

I need to redirect e-mail within our MTA when the two following criteria are both true: When an e-mail is: Sent from: [email protected] Addressesd to: [email protected] Result: redirect e-mail to ...
Michael P's user avatar
  • 297
5 votes
3 answers
866 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
1 answer
22k views

IIS7.5 redirect IP to domain

But stuck on this one, looked on google but couldnt find anything. The deployment of the site went slightly wrong and some pages were being saved as: http://73.34.12.../page.aspx Where the IP was ...
Tom Gullen's user avatar
4 votes
1 answer
2k views

Redirect all subdomains to main domain with HTTPS without a wildcard cert (nginx)

I have a domain name with a main site and a few vhosts. I want all sites (main and vhosts) to only be accessible through HTTPS (using HSTS), and I want non-existing subdomains to be redirected to the ...
Joe La Frite's user avatar
4 votes
5 answers
4k views

Redirect to www subdomain via DNS

Is it possible to set a DNS record to redirect all example.com/* traffic to www.example.com/*? I'm running a Sinatra app on Heroku's Cedar stack. I set up Heroku's Custom Domains addon, and the ...
ma11hew28's user avatar
  • 799
3 votes
3 answers
8k views

Insecure Connection: issue on www redirect to non-www with https

I am not much familiar with server configurations, please help me on this issue: I have a Debian8 server and a SSL certificate, the SSL certificate only for My non-www domain so I would like to ...
Riyas Muhammed's user avatar
3 votes
1 answer
19k views

Apache Virtual Host redirect from subdomain to subdirectory

How do I redirect requests coming to http://blog.mysite.com to http://mysite.com/blog? Reading the apache docs on when not to use the rewrite mod, I tried a simple redirect e.g. Redirect http://blog....
Ben McCormack's user avatar
3 votes
2 answers
13k views

Possible to redirect from HTTPS to HTTP behind load-balancer?

I have a basic ASP.NET application that sits behind an F5 load-balancer. Incoming SSL requests (over HTTPS) terminate at the load-balancer and all internal communication between the load-balancer and ...
Derek Hunziker's user avatar
3 votes
1 answer
16k views

How to redirect Https CONNECT Request with Squid Explicit Proxy

I want to block certain urls for some users of my internal network. I am using a squid based explicit proxy for this purpose with a redirect_program. The clients are configured to use a pac file for ...
muzammil's user avatar
2 votes
1 answer
592 views

Communication between Apache and glassfish

We are currently using HTTPD server (apache) to handle client request. The requests are further proxied to a Application Server (glassfish) which provides the content. The content are static files (...
TheMonkWhoSoldHisCode's user avatar
2 votes
2 answers
3k views

NGINX - Redirecting www to non-www after redirecting http to https

I've checked out quite a few other answers to similar questions as well as tutorials on DigitalOcean, etc., with no success. Sorry for what is probably a very obvious problem - I'm new to this. ...
Lewis's user avatar
  • 23
1 vote
1 answer
498 views

nginx: Redirect https traffic without subdomain to subdomain (non-www to www)

My current ssl certificate covers the subdomains www.example.com and static.example.com So if a users try to access my site via https://example.com I want to redirect him to https://www.example.com . ...
paskster's user avatar
  • 301
1 vote
3 answers
30k views

Is it possible to set the default web site to redirect to a virtual directory in IIS [duplicate]

Can you set up a website to make a default redirect to a virtual directory? I tried to do this but it overrode every single website in my setup to that redirect. I want to be able to open http://...
Spence's user avatar
  • 680
1 vote
1 answer
2k views

how to redirect www.example.com to example.com via htaccess while on zend framework

as you may know zend framework uses .htaccess for redirection purposes so when I tried to follow this advice: http://techpp.com/2010/06/28/how-to-redirect-www-urls-to-non-www-urls-and-non-www-to-www/ ...
kamikaze_pilot's user avatar
1 vote
2 answers
3k views

Apache redirect all requests to https www

This question has been asked, but I'm not finding the solution. I have very little apache experience. I need to set up my server to take the following requests http://, http://www. and https:// and ...
MAZUMA's user avatar
  • 163
1 vote
3 answers
6k views

Disable HTTPS for a domain that shares IP with another domain that is under HTTPS

I am running into a weird problem trying to disable HTTPS for one domain, but the other domain has HTTPS. They both are different websites running on a dedicated server, sharing the same IP address ...
MacMac's user avatar
  • 2,141
1 vote
1 answer
2k views

VirtualHost ignores ServerName and ServerAlias

I'm trying to redirect all the traffic from .se to .com but for some reason the VirtualHost ignores the ServerName and ServerAlias that I define. <VirtualHost *:80> ServerName www.example....
user152440's user avatar
0 votes
3 answers
1k views

apache rewrite to assign folders to domains

Please point me in the right direction. I am using .htaccess to set-up domains on my server. I need to domain.com to access files from /domain.com/* folder. If a file does not exist, load /domain....
Alex L's user avatar
  • 591
0 votes
0 answers
23 views

masking after redrection using .htaccess [duplicate]

I have read many examples that use the .htaccess file method to mask a url. None of them works for me. It might be something simple that I am missing. Please bare with me. Here is what i want to do: I ...
thermike's user avatar
0 votes
1 answer
10k views

apache redirect only root slash homepage [duplicate]

I need to redirect only http://example.org/ to http://www.something-other.org/ in Apache 2.4. Just the homepage. Nothing else. I.e. http://example.org/?page=blog or http://example.org/contact.html ...
rubo77's user avatar
  • 2,519
0 votes
1 answer
621 views

Apache redirect to another domain all URLs, except for ones starting with substring

Can anyone help me achieve a redirect in Apache from http://subdomain.example.com/ to http://example.com/ for all URLs, EXCEPT the ones starting with "files/"? Thank you
bogdan's user avatar
  • 155