1

First time using .htaccess so I come here to have a bit of help since the web is not that file with informations (or I just don't find them :/).

So the idea is that I want to redirect link ending by /2/ or /3/ ... (number) to the error410 page.

So I came up with this regex which is working well ^(.*?)\/(?!(?:404|410)$)\d+$

Test Here

And if I get how this is working this is the right solution :

RewriteCond %{QUERY_STRING} ^(.*?)\/(?!(?:404|410)$)\d+$ [NC]
RewriteRule . - [G]

Do you think this will work or not ? I don't want to play the apprentice wizard..

1
  • 1
    in fact it do lot of things, you should use RewriteCond %{QUERY_STRING} /[0-9]+/$ cause your request work ending by number but not ending by number + slash. Do you have to not redirect /404/ and /410/ request too ?
    – Froggiz
    Nov 3, 2015 at 15:04

1 Answer 1

0

It will not work. You are testing for the pattern against the %{QUERY_STRING} variable. This variable does not store the URI content, but instead the query parameters as sent by GET or POST.

To send the GONE status, use the following rule:

RewriteEngine On
RewriteRule ^\d+/?$ - [G]

You must log in to answer this question.

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