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:
domain.com/article/some-sluggish-link/?report=1 #number at end
Regex to find this:
\?report=\d*$
For this i want 301 redirect to:
domain.com/article/some-sluggish-link/
I nginx.conf I have 3 redirections:
server {
listen 80;
server_name subdomain.example.com.; #just one subdomain
}
server {
listen 80;
server_name *.example.com;
return 301 http://example.com$request_uri;
}
server {
listen 80;
server_name example.com;
}
and it works; it redirects 301 all www., ww., aaa., and every subdomain, except 1 particular, to main domain.com
I'd appreciate any help
Cheers!
EDIT 25/03/2015
I already have "location /" in my conf file:
location / {
uwsgi_pass unix://opt/run/ps2.sock;
include uwsgi_params;
}
which redirects to some django app. After applying 'if' clause it gives me infinite loop!!!
My problem is basically with SEO, meaning google indexes some certain pages (those with '?report=' parameter) that are copies of urls without this trailing parameter.
I wanted googlebot to stop indexing using robots.txt, but the problem is you can't use regexps in this file. Also I can't say which url exactly nedd to be redirected or stopped from indexing cause it happens somehow randomly...
Comments
Post a Comment