Override rule for number discovery

I am trying to create a rewrite rule that will only determine numbers and forward them accordingly. I want the rewrite rule to be ignored if nothing but numbers.

  • /index.php - OK
  • / - OK
  • /42365 - rewrites to view.php?id=42365

What I still have:

 RewriteEngine on RewriteRule ^([0-9]+)?$ view.php?id=$1 [L] 
+6
source share
1 answer

Delete it ? from the end of the group ([0-9]+) , which makes it optional. You must have overwriting numbers:

 RewriteEngine on RewriteRule ^([0-9]+)$ view.php?id=$1 [L] 
+8
source

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


All Articles