Reputation: 2436
OK. I have this regular expression in my .htaccess file to rewrite / anything alphanumeric to index.php?id=alphanumeric string.
RewriteEngine on
RewriteRule ^([A-Z-a-z0-9]+)$ index.php?id=$1
the problem i'm having is that when some other variables get added to that string, everything stops working.
For example:
www.someaddress.com/ABCDEFGH works fine.
www.someaddress.com/ABCDEFGH&othervariable=123 fails.
I know my alpha numeric string is always 8 characters. is there a way to make the regular expression only match 8 and leave the rest of the string?
Thanks in advance.
Upvotes: 1
Views: 1358
Reputation:
try this:
RewriteRule ^([A-Za-z0-9]{8}) index.php?id=$1
Please note the -
character between Z
and a
is not required
Upvotes: 2
Reputation: 975
Something like that should do the trick. You want to remove the $ to let it ignore the rest of the variables.
RewriteRule ^([A-Z-a-z0-9]{8}) index.php?id=$1
Upvotes: 2