Nginx location fix: redirection to index.html

I am running nginx v 1.0.4, and we are trying to do the following:

location ~ ^/${ 
rewrite ^.*$ /index.html last;
}

Basically: if the user reaches the default domain http://www.foo.com or http://www .foo.com/ redirects it to http://www.foo.com/index.html

When I add it to my conf file, I get the following:
Start nginx in /etc/nginx/myconf.conf: nginx: [emerg] unknown command “”

Thanks in advance.

You can use the rewrite function without a location

rewrite ^/$ /index.html last;

Or permanent redirection

rewrite ^/$ /index.html permanent;

Rewrite with parameters, for example http://www.foo.com/?param=value –> http://www.foo.com/index.html?param=value

rewrite ^/ (\?.*)?$ /index.html$1 permanent;

I am running nginx v 1.0.4, and we are trying to do the following:

< /p>

location ~ ^/${
rewrite ^.*$/index.html last;
}

Basically: if The user reaches the default domain http://www.foo.com or http://www.foo.com/ and redirects them to http://www.foo.com/index.html

When I add it to my conf file, I get the following:
in Start nginx in /etc/nginx/myconf.conf: nginx: [emerg] unknown command “”

Thanks in advance.

You You can use the rewrite function without a location

rewrite ^/$ /index.html last;

Or permanent redirection< /p>

rewrite ^/$ /index.html permanent;

Rewrite with parameters, such as http://www.foo.com/?param=value –> Http://www.foo.com/index.html?param=value

rewrite ^/(\?.*)?$ /index.html$1 permanent ;

Leave a Comment

Your email address will not be published.