Reputation: 2984
In htaccess file I have that line:
RewriteRule ^something,([0-9]+)\.html$ something.php?num=$1 [L]
And if I open page with any number like something,7.html
then everything works perfect, but how can I change rewrite rule if I want use a negative numbers as well, for example something,-2.html
. Also I don't want to allow use letters.
Upvotes: 0
Views: 520
Reputation: 34632
Adjust your regular expression to check for an optional "minus":
^something,(-?[0-9]+)\.html$
Upvotes: 1
Reputation: 143886
You want to add a \-?
inside your match selection:
RewriteRule ^something,(\-?[0-9]+)\.html$ something.php?num=$1 [L]
Upvotes: 0