Nick Williams
Nick Williams

Reputation: 23

Nginx Rewrite Rules - All Sub Folders

I am migrating site and bringing all my product urls to top level.

Example:

Old URL: http://www.example.com/sub/folder/product.asp Old URL: http://www.example.com/sub1/folder1/product.asp

New URL: http://www.example.com/product.asp

I am struggling to get the nginx rewrite rule to work how i need it. Basically anything that ends in *.asp need to strip out all the folder paths.

Upvotes: 1

Views: 486

Answers (1)

Richard Smith
Richard Smith

Reputation: 49812

You need to identify URIs ending with .asp that include more than one /. One possible solution might be:

rewrite ^/.+(/[^/]+\.asp)$ $1 permanent;

See this document for details.

Upvotes: 1

Related Questions