3 ms·
For most people the solution is very simple. Use a rewrite rule in your web server config. In nginx: if ($host !~ "^(example.com|beta.example.com|valid.exam
by staunch 16y ago
For most people the solution is very simple. Use a rewrite rule in your web server config. In nginx:
if ($host !~ "^(example.com|beta.example.com|valid.example)$") {
rewrite ^/(.*)$ http://example.com/$1 permanent;
}
http://www.example.com/about http://www.example.com/about
or
http://fuckshit.example.com/about http://fuckshit.example.com/about
becomes
http://example.com/about http://example.com/about
This is good practice in any case, so that you're always serving up the canonical URL.
- nathanhammond 16y agoI would much rather http://fuckshit.example.com/ http://fuckshit.example.com/ end up at a browser error page instead of being redirected to my site. This prevents the clever person who decides to link to me with http://fuckshit.example.com/ http://fuckshit.example.com/ as the URL. (And I use mod_rewrite for naked domain to www redirect, so I'm familiar with this.)