Using WP3.1
I Have a custom page with a WP_Query and the query gets dynamic variables from the url. And i want safe variables and clean urls.
Example:
carpage/?carmodel=honda&location=finland
TO
carpage/honda/finland/
I made add_rewrite_rule in to functions.php and it works, but iam not sure it's safe to use this.
Functions.php
function fcars() {
add_rewrite_rule('carpage/[/]?([a-zA-Z-]*)[/]?([a-zA-Z-]*)$', 'index.php?pagename=carpage&var1=$matches[1]&var2=$matches[2]');
add_rewrite_tag('%var1%', '[a-zA-Z]+');
add_rewrite_tag('%var2%', '[a-zA-Z]+');
}
add_action('init', 'fcars');
And in Custom template i get the vars
Could someone please help me with this. How can i make this safe to use and is this the right way in WP3.1
What is the right way to make add_rewrite_rule in this case:
carpage/honda/finland/
(just hyphens and small letters in url) carpage is the static template page.