Pergunta

Hi I have implemented a Rails app with nginx and deployed on Amazon Web Services.

I have written different rules for 301 redirection.

On of them is the following in nginx.conf:

rewrite (?i)^/abc/HomePage.aspx(.*) /#!/Home$1 permanent;

However I am able to redirect to home page but am having trailing characters in the URL, which can be dynamic.

For example, if the URL (old site) is http://x3.com/abc/HomePage.aspx?_=72HNtUhJkGN5yXngjof0jLZ1yv7ykDfnNwsiYcgx9xqpVoLH0UvC5nneQnFfwTQnnC5w4nYtXuBc7DIA16BxkA==

it is landing on http://www.x3.com/#!/Home?_=72HNtUhJkGN5yXngjof0jLZ1yv7ykDfnNwsiYcgx9xqpVoLH0UvC5nneQnFfwTQnnC5w4nYtXuBc7DIA16BxkA

I just want to remove the trailing part which is _=72HNtUhJkGN5yXngjof0jLZ1yv7ykDfnNwsiYcgx9xqpVoLH0UvC5nneQnFfwTQnnC5w4nYtXuBc7DIA16BxkA

and land on http://www.x3.com/#!/Home

How do I achieve this?

Foi útil?

Solução

You need to add a trailing ? to the rewrite url as per the docs:

rewrite (?i)^/abc/HomePage.aspx(.*) /#!/Home$1? permanent;

Make sure to clear the browser cache before testing.

Also, regarding permanent redirection refer to this answer.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top