Netlify fbclid redirects - facebook

Can you please help me with the netlify redirect rules for the new fbclid field that Facebook adds to urls? It is terrible for analytics and cache.
What I have tried:
/mysite.test/*fbclid /mysite.test/:splat 301

Redirects on Netlify have specific rules that aren't always as clear until you test them.
With no extra splat:
https://example.com?id=23&fbclid=huihd8239732buibiee32809jeee2i90
You will need a redirect without any wildcard and :splat
/ id=:id fbclid=:fbclid / 301
redirects to: https://example.com
With extra splat:
https://example.com/test?id=23&fbclid=huihd8239732buibiee32809jeee2i90
A redirect with the wildcard and :splat would be needed
/* id=:id fbclid=:fbclid /:splat 301!
redirects to: https://example.com/test
Solution for above examples combined
_redirects
/ id=:id fbclid=:fbclid / 301
/* id=:id fbclid=:fbclid /:splat 301!
Note: ALL parameters must match to catch the redirect case. In the example above, if there was only an fbclid parameter then you should have the following to catch it.
_redirects
/ fbclid=:fbclid / 301
/ id=:id fbclid=:fbclid / 301
/* fbclid=:fbclid /:splat 301!
/* id=:id fbclid=:fbclid /:splat 301!
Warning: DO NOT setup a redirects similar to the below examples. They will cause an infinite redirect:
Do not try to redirect to the same paths to strip or add a trailing /. Use the admin panel and change the pretty URL settings (Build & deploy > Post processing > Asset optimization).
# Do Not ever do these in your redirects
/some-path /some-path/ 301!
/* /:splat/ 301!

Related

Moving HTTP site to HTTPS on Netlify - 301 Redirects and SEO

I am moving my old HTTP site to Netlify and need some guidance on 301 redirects and SEO.
I will be using netlify.toml for redirects.
Netlify will automatically redirect http://www.example.com to https://www.example.com so I'm assuming that a redirect rule is not needed for this case.
Question 1: For http://example.com to https://www.example.com - should I do this in DNS or 301 redirect rule in netlify.toml?
For the following URL
http://www.example.com/directory/page1.html
Question 2: Should I use relative or absolute URLs to redirect? Which from below would be a best-case scenario?
[[redirects]]
from = "/directory/page1.html"
to = "https://www.example.com/directory/:splat"
status = 301
force = true
[[redirects]]
from = "http://www.example.com/directory/page1.html"
to = "https://www.example.com/directory/:splat"
status = 301
force = true

IIS7 HTTP Redirect - how to drop/ignore the original's relative path?

Using IIS7's built in "HTTP Redirect" for a site.
Problem
Entering: original.com/abc/efg
Gives: redirect.com/abc/efg - which is not a page on the redirect destination!
I want
Entering: original.com/abc/efg
Gives: redirect.com
I already Checked "Redirect all requests to exact destination"
Note - while original.com/abc/efg does NOT give redirect.com...
original.com/abc/efg/ (include ending slash) DOES give redirect.com. Bug with IIS7 HTTP Redirect?

Redirect a url to www with haproxy getting too many redirects

I have an haproxy that I want to reroute only one url from test.ai to www.test.ai
redirect prefix https://www.test.ai code 301 if { hdr(host) -i test.ai}
But for some reason I get the test.ai redirected you too many times.
You appear to have a redirect set somewhere else. If you're using Wordpress as a backend. You need to set your site URL and home.
define( 'WP_HOME' , 'https://test.ai');
define( 'WP_SITEURL', WP_HOME . '/');
Then you'll need to add:
if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
$_SERVER['HTTPS']='on';
Finally be sure this is at the bottom...
require_once(ABSPATH . 'wp-settings.php');
Otherwise, you may have a redirect or rewrite in your apache/nginx setup

Nginx redirect http to https and remove trailing slashes with one single redirect

I want to redirect http to https and remove trailing slashes in nginx with one single redirect. The solution I have today is the following:
server {
listen 80;
server_name www.example.com
rewrite ^/(.*)/$ /$1 permanent;
return 301 https://$host$request_uri;
}
The problem with this solution is that it will give two redirects
Gives Two redirects:
http://www.example.com/test/ --> http://www.example.com/test
http://www.example.com/test --> https://www.example.com/test
Is it possible to make a solution where you only get one single redirect like bellow?
http://www.example.com/test/ --> https://www.example.com/test
when I looked through the documentation of nginx rewrite and return methods I felt like it should be possible to do it with a single rewrite somehow:
rewrite ^/(.*)/$ https://$host$request_uri permanent;
But nothing I have tried have given me the correct results.
You already had the components of a correct solution. Use the scheme and hostname, together with the capture to construct the destination URL:
rewrite ^/(.*)/$ https://$host/$1 permanent;

Redirection from www.example.com to www.example.com/index.jsp

I have setup apache2 and tomcat7 on ubuntu 14.04.
my domain name is www.example.com , which I want to redirect to the www.example.com/index.jsp on to the tomcat as this is the login page. How can this be done? The set up works fine for a request made to www.example.com/index.jsp. The apache virtualHost setting is
ProxyPass / ajp://localhost:8009/
ProxyPassReverse / ajp://localhost:8009/
the redirection in my understanding should happen on the apache. As the apache is acting just as a proxy and not serving any requests by itself can we use the directive ? Where and how to make the change. Any pointers appreciated
I tried rewriting the url in the virtualHost but it doesn't seem to be working
ServerName www.example.com <br>
RewriteEngine On <br>
RewriteRule ^http://www\.example\.com$ https://www.example.com/index.jsp [R]
You can use the following rewrite rule
RewriteEngine On
RewriteRule ^/$ /index.jsp [R]
It basically will search that if, the uri path starts and ends with a / it will redirect it to /index.jsp , this should do the trick.