0

I'm having a small issue - my error log is filling up with requests to a directory folder on my site (but with added data that shouldn't be there).

http://example.com/the-directory/undefined
http://example.com/the-directory/administrator
http://example.com/the-directory/admin
http://example.com/the-directory/script

How can setup a rewrite so any requests that contains :

/the-directory/{any extra data}

301 redirects to

/the-directory/

What I have tried is :

rewrite ^/the-directory/(.*)$ /the-directory/ last;

But that just gets stuck in a redirect loop. Any help would be greatly appreciated.

2
  • If these are not legitimate requests, you should probably just continue sending the 404 error. Dec 3, 2013 at 3:57
  • those are just some examples - some are legit requests (which appears to be a typo in the link to my site) Dec 3, 2013 at 4:01

1 Answer 1

2

Try this one:

rewrite ^/the-directory/.+$ /the-directory/ permanent;

You stuck in a redirect loop because regex ^/the-directory/(.*)$ matches /the-directory/.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .