I’m here to help members learn to create good mod_rewrite code (rather than offer free coding) so I’ll ask you first to read the tutorial linked in my signature then make a valid attempt. Post your code and I’ll be happy to critique it and offer additional pointers to get you where you want to go.
BTW, that’s basically what WordPress’s mod_rewrite does and they do a good job despite a few missteps that noobies might not be aware of. Look through this board for examples (and my critique).
Your rewrite rule is backwards (or so it seems)
Since you want to capture /variable/ and redirect it to index.php?data=variable, you want to do the following
RewriteEngine On
RewriteRule ^variable/? index.php?data=variable [L]
Then when you want to make it capture // and redirect to index.php?data=, you can do the following
RewriteEngine On
RewriteRule ^([a-zA-Z0-9]+)/? index.php?data=$1 [L]
Good reply except that I’d prefer to check that the request is not for a directory (or extensionless file) before your RewriteRule. That’s important as not to do so could disable important functionality.
krishna,
If you read the tutorial, you’d have known that your attempt was “backward” as cp noted. It’s worthwhile to spend the time to read and understand the tutorial and look through the sample code (and explanations) at the end.