HTACCESS forwarding using ID parameter number

I hope someone can help as this is hard to understand.

I am trying to redirect through HTACCESS and mod_rewrite several pages with a URL parameter identifier in a specific range (from 1 to 7603).

Here is what I still have:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} &?id=\b([1-9][0-9]{0,2}|[1-6][0-9]{3}|7[0-5][0-9]{2}|760[0-3])\b [NC]
RewriteRule ^example\.php$ http://www.website.com/? [R=301,L]
</IfModule>

Currently, it redirects the page if there is an ID-URL parameter, but redirects any identification number, and not just those that are specified in the specified range, for example. it will redirect ID = 10000, although this should not be.

Does anyone know what I did wrong, and how can I fix it?

+4
source share
1 answer

: \b((\d{1,3})|([1-6]\d{3})|(7[0-5]\d{2})|(760[0-3]))\b

:

  • 0 <= ID <= 999: \d{1,3}
  • 1000 <= ID <= 6999: [1-6]\d{3}
  • 7000 <= ID <= 7599: 7[0-5]\d{2}
  • 7600 <= ID <= 7603: 760[0-3]

0

Source: https://habr.com/ru/post/1544153/


All Articles