Reputation: 3296
I am trying to create a rewrite rule which will detect numbers only and forward them accordingly. I want the rewrite rule to be ignored if anything but numbers appears.
/index.php
- OK/
- OK/42365
- rewrites to view.php?id=42365
What I have so far:
RewriteEngine on
RewriteRule ^([0-9]+)?$ view.php?id=$1 [L]
Upvotes: 7
Views: 7427
Reputation: 270609
Remove the ?
from the end of the ([0-9]+)
group, which makes it optional. You must have numbers for the rewrite to occur:
RewriteEngine on
RewriteRule ^([0-9]+)$ view.php?id=$1 [L]
Upvotes: 10