I've got username working just fine, but I have a "show more posts" button which goes to profile.php?name=$username&l=$limit + 10 So I need to rewrite that one as well. Here is my rewrite for the /a/Username thingy:
RewriteRule ^a/([^/]+)$ profile.php?name=$1
Can anyone do anything like this where it's more like ?name=$1&l=$2 and then go /a/$1/p/$2 ?
No just rewriting if that's what you meant? I just put the script I wrote in my .htaccess file and then /a/username work's just like /profile.php?name=username
I want profile.php?name=username&l=10 to corespond to a/username/10 ( I know I wrote /p/10 above, but it doesn't really matter
Firstly I don't think you're example is particularly safe, as ([^/]) matches exeverything except '/'. There are other characters you'll want to ignore as well as they are non URL safe, so it's best to write the rule with the characters you want
profile.php?name=$username&l=$limit + 10So I need to rewrite that one as well.Here is my rewrite for the /a/Username thingy:
Can anyone do anything like this where it's more like ?name=$1&l=$2 and then go /a/$1/p/$2 ?
I want
profile.php?name=username&l=10to corespond toa/username/10( I know I wrote /p/10 above, but it doesn't really matterI want
profile.php?name=Schart&l=20To go to
/a/Schart/20I normally use one variable then break it into an array using that way /username/10 would equal to $url[0]='username'; $url[1]='10';
It also means you can have really long URLs
*nb the rtrim is to stop an additional slash from breaking it
This will match anything like a/Schart-Test_URL01/20
if you want the preceeding '/' before the 'a' then add one /a/([a-zA-Z0-9\-_]+)/([0-9]+)$
Try your new rules on the following tool http://gskinner.com/RegExr/