What regex do I need for this rewrite rule:
domain.com/a-number
to domain.com/index.php?page=a-number
I did this one:
RewriteRule ([1-9]+) index.php?page=$1 [NC]
but was not good.
Any suggestions?
Simple one
Moderator: General Moderators
-
klevis miho
- Forum Contributor
- Posts: 413
- Joined: Wed Oct 29, 2008 2:59 pm
- Location: Albania
- Contact:
-
klevis miho
- Forum Contributor
- Posts: 413
- Joined: Wed Oct 29, 2008 2:59 pm
- Location: Albania
- Contact:
Re: Simple one
Never mind, I've got it:
RewriteRule ^([1-9]+)$ index.php?page=$1 [NC]
RewriteRule ^([1-9]+)$ index.php?page=$1 [NC]
- ridgerunner
- Forum Contributor
- Posts: 214
- Joined: Sun Jul 05, 2009 10:39 pm
- Location: SLC, UT
Re: Simple one
Your regex doesn't allow for the numbers, 10, 20, etc since it doesn't include the digit zero. Try this one ...
[text]RewriteRule ^([1-9]\d*)$ index.php?page=$1 [NC][/text]
[text]RewriteRule ^([1-9]\d*)$ index.php?page=$1 [NC][/text]
-
klevis miho
- Forum Contributor
- Posts: 413
- Joined: Wed Oct 29, 2008 2:59 pm
- Location: Albania
- Contact:
Re: Simple one
Thanks, but wouldn't this: ^\d+$
be better?
be better?
- ridgerunner
- Forum Contributor
- Posts: 214
- Joined: Sun Jul 05, 2009 10:39 pm
- Location: SLC, UT
Re: Simple one
Yes, if you wish to allow page zero.