0

I create a page on wordpress and put php file on it. Now i can use it like that.

saita.com/wp_page_name/?name=blqbl&name2=name2 is to long

My question is how to rewrite .htaccess because I want my link to be like

saita.com/wp_page_name/name1/name 2 is to long

I forgot... my php file is in main root..

I tried to put in my .htaccess

RewriteRule ^(.+)/([a-zA-Z0-9-_]+)?$ upcoming.php?league=$1&division=$2

but it doesn’t work..

EDIT: If i get it right, i should change my .htaccess or should i put some new code in functions.php ?

EDIT2: I added this code

     add_action('init', 'custom_rewrite_rule', 10, 0);
function custom_rewrite_rule() {
    add_rewrite_rule('^machove/([^/]*)/([^/]*)/?','index.php??pagename=machove&league=$matches[1]&division=$matches[2]','top');
}

add_filter('query_vars', 'foo_my_query_vars');
function foo_my_query_vars($vars){
    $vars[] = 'league';
    $vars[] = 'division';
    return $vars;
}

at the end of my functions.php, then i resave my permalinks and now when i open saita.com/machove/name1/name2 , my page info is from saita.com/machove/ but the url is saita.com/machove/name1/name2

  • See also: [Reference: mod\_rewrite, URL rewriting and "pretty links" explained](http://stackoverflow.com/q/20563772) - Your question is lacking the concrete directory setup, folder relation, `.htaccess` location. And bland `.+` placeholders are highly unsuitable as first capture group anyway. – mario Jul 08 '15 at 14:26

1 Answers1

0

Use following:

RewriteRule wp_page_name/(.*)/(.*) /wp_page_name/name1=$1&name2=$2
Martin
  • 139
  • 11
  • i think i didnt make it right. my url now is saita.com/machove/?league=England&division=Premier%20League i make my .htacess like that and it didnt work.. RewriteRule machove/(.*)/(.*) /machove/league=$1&division=$2 – Димитър Димитров Jun 22 '15 at 15:45