Morning all - another Sunday, another stupid question from me.
I have the URL: http://domain.com/w4sG7A which has a random 6 character string that I would like to get mod_rewrite to rewrite the URL to domain.com/script.php?w4sG7A but only if there is the 6 character string.
If there is no 6 character string, or if it is more than or less than 6 characters, just go to the index page as normal.
Now, as far as I can see I need to search for the 6 characters using:
/[a-zA-Z0-9]{6}/
but how do I get that to check after the / of the domain name?
I have my 'regex for complete numpties' book on the way so hopefully this will be one of the last questions on regex from me.
Not sure why, but I just cannot get my head round this thing!
Cheers
M.
//EDIT: Forgot to put what I tried:
I have the URL: http://domain.com/w4sG7A which has a random 6 character string that I would like to get mod_rewrite to rewrite the URL to domain.com/script.php?w4sG7A but only if there is the 6 character string.
If there is no 6 character string, or if it is more than or less than 6 characters, just go to the index page as normal.
Now, as far as I can see I need to search for the 6 characters using:
/[a-zA-Z0-9]{6}/
but how do I get that to check after the / of the domain name?
I have my 'regex for complete numpties' book on the way so hopefully this will be one of the last questions on regex from me.
Not sure why, but I just cannot get my head round this thing!
Cheers
M.
//EDIT: Forgot to put what I tried:
Code:
RewriteEngine On
RewriteRule /[a-zA-Z0-9]{6}/$ http://domain.com/redir.php?i=$1 [R,L]
Last edited: