rewrite rule to remove trailing dot from hostname
Igor Sysoev
is at rambler-co.ru
Wed Aug 27 11:07:04 MSD 2008
On Wed, Aug 27, 2008 at 02:11:32AM +0200, Andrew Grim wrote:
> Right now users can browse my site via either "http://<hostname>.com" or
> "http://<hostname>.com.". Notice the trailing dot. So because of some
> flash security issues I want to redirect the hostname with the trailing
> dot to my regular hostname. Should be easy, right?
>
> I've tried a bunch of things, and it appears that $host doesn't include
> the trailing dot. But if it doesn't, does anything?
>
> if ($host ~ "<host_name>.com\." ){
> rewrite ^(.*) http://<%= http_host_name %>$1 permanent;
> }
>
> I've also tried
>
> if ($host ~ "\.$" ){
> rewrite ^(.*) http://<%= http_host_name %>$1 permanent;
> }
>
> And a number of other things. Any ideas would be greatly appreciated!
The $host has no trailing dot, use original $http_host instead.
--
Igor Sysoev
http://sysoev.ru/en/
More information about the nginx
mailing list