I have site running and wish to convert the url
This requirement is opposite to the usual method to convert dynamic url to static url
How can this be achieved with mod rewrite rules
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).
Below is what I have written
RewriteRule ^index\.php\?data\=variable$ /variable [L]
And I wish to request the following from browser:
to get redirected to
However this doesn't redirect
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
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
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.
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.
Bah! :headbang: I knew that! I can't believe I forgot it. Next time I'll nail it!
:tup: Not bad anyway!
This topic is now archived. It is frozen and cannot be changed in any way.