5 votes

.htaccess - Redirect all URLs with one exception

As mod_alias is recommended for simple redirects, here's the solution with mod_alias: # Specific redirects: Redirect 301 /old-prefix https://www.example.com/ Redirect 301 /another-old-prefix/ https://...
  • 44.8k
4 votes
Accepted

.htaccess - Redirect all URLs with one exception

You are mixing mod_rewrite (RewriteCond, RewriteRule) and mod_alias (Redirect, RedirectMatch). The stray mod_rewrite RewriteCond directive will not do anything here. This directive only applies to the ...
  • 12.1k
3 votes

Redirect Large Number of Web Sites from Azure to AWS

Each site's DNS contains an A record pointing to an old IP address which is being decommissioned. Updating that A record or adding a CNAME record would be very difficult and time consuming Yes. ...
  • 74k
3 votes
Accepted

Make nginx redirect to HTTPS even with competing location regex

My Suggestion would be server { server_name example.com *.example.com; listen 80; listen [::]:80; return 301 https://$host$request_uri; } this would create a ...
  • 1,507
2 votes

On synology dsm, add a specific nginx config to a specific virtual host

You cannot change this config, but you can extend it by using the mentioned user config file at the bottom. In your example /usr/local/etc/nginx/conf.d/ecd72a1b-c840-494f-8d6a-a837da4e0d94/user.conf. ...
  • 121
2 votes

Redirect part of a URL parameter to the URL-Path

RewriteCond %{QUERY_STRING} ^create_account=([0-9]+)&back=([0-9]+)$ RewriteRule /login https://example.com/product/%1/? [L,R=301] This tries to match a back URL parameter whose value consists ...
  • 12.1k
2 votes

Simple IP/URL Redirection

We will provide a simple interface in our application that asks for their own website IP/URL and redirect their website to ours. You can't do that. That would be a major security vulnerability. They ...
  • 5,793
2 votes
Accepted

Configure SSL for Apache Reverse Proxy

The error you get means that the subject alternative names in the certificate do not match the hostname from the URL you visit. According to your config you seem to use the same certificate both for a....
1 vote
Accepted

How to setup 301 redirections in GCP load balancer?

There is a possibility of URL redirection in GCP Load balancer and from the information provided by you it is observed that a bucket and a Global HTTPs Load balancer were created in your environment. ...
1 vote

nginx reverse proxy with docker containers and specific nested locations

There's a few of things going on here that we need to get on the same page for this to work: NGINX configuration: path based routing, reverse proxy I've tried your config, and I believe your config ...
1 vote
Accepted

htaccess: 301 redirect defined URLs to new domain and catch all redirect the rest

Redirect is a mod_alias directive (nothing to do with RewriteEngine). RewriteRule belongs to mod_rewrite. mod_rewrite is always processed first, despite the apparent order of the directives in the ...
  • 12.1k
1 vote

Apache2 how to generate random string for subdomain

The Redirect directive expects a fixed URL. So that won't work. The easiest will probably to use mod_rewrite to redirect all requests to script and then let your script, for example a redirect.php PHP ...
  • 1,713
1 vote
Accepted

Change upstream response from 302 to 301 in nginx

You can change the 3xx status code by using proxy_intercept_errors and error_page as you suggest. You will need to use the value from $upstream_http_location to reconstruct the Location header in the ...
1 vote

How do I redirect "old.foo.com/foo" to "new.foo.com/foo" with a NGINX K8S ingress, without breaking cert-manager?

After some blind experimentation, it actually seems to work to place $request_uri into the target URL in the "permanent-redirect" annotation. I'm guessing it's passed directly into the NGINX ...
  • 1,118
1 vote

Best way to do 301 redirects

Just to clarify -- is this a situation where using a CDN, for whatever reason, is completely off the table? If not, I recommend Page Rules via Cloudflare's free plan, which is what I personally use to ...
  • 155
1 vote
Accepted

Best way to do 301 redirects

Basically there are a few options for the redirect and I don't think there is one best way, it depends on the use case. Placement of the Redirect Virtual Host Prerequisite: You need administrative ...
  • 340
1 vote

Apache Conditional Redirect HTTP to HTTPS

In my Virtualmin server, following line did the trick. RedirectMatch ^/(?!.well-known)(.*)$ https://phpmyadmin.example.com/$1
1 vote

Can I use Apache variables with mod_alias's `Redirect`, instead of using mod_rewrite?

A bit late, but ran across this thread looking w/ just this problem and found a solution. With Apache 2.4 you can't do: Redirect permanent /login https://%{SERVER_NAME}/login But you can do: <...

Only top scored, non community-wiki answers of a minimum length are eligible