Jump to content

[email protected]

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Everything posted by [email protected]

  1. Thank you very much ChristianF, this solved my problem. I appreciate your concern.
  2. Hey, the error must be at copy & paste time, my bad, I was trying to paste only what's important to avoid confusion. Here is the fixed code: <code> function insert_rewrite_rules( $rules ) { $newrules = array(); $page_name = 'mypage'; //basic rule $newrules['(' . $page_name . ')$'] = 'index.php?pagename=$matches[1]'; //search by id $newrules['(' . $page_name . ')/(\d+)$'] = 'index.php?pagename=$matches[1]&id=$matches[2]&search=1'; //url with page included $newrules['(' . $page_name . ')(/(\w+)-bedrooms)*(/(\w+)-bathrooms)*/([^.]+)/(\d+).html$'] = 'index.php?pagename=$matches[1]&bedrooms=$matches[3]&bathrooms=$matches[5]&query=$matches[6]&pagem=$matches[7]'; //url with no page $newrules['(' . $page_name . ')(/(\w+)-bedrooms)*(/(\w+)-bathrooms)*(/([^.]+))*$'] = 'index.php?pagename=$matches[1]&bedrooms=$matches[3]&bathrooms=$matches[5]&query=$matches[7]'; return $newrules + $rules; } add_filter( 'rewrite_rules_array','insert_rewrite_rules' ); </code> I figured it out that wordpress interprets the &page=2 querystring and redirects to "mysite.com/2" url automatically, so I changed the "page" param to "pagem", only to avoid wp redirection. Anyway, I need the regex to catch the number of the page the user is requesting. Thanks again
  3. Hi, thanks for the replay, here is the code I'm using: function insert_rewrite_rules( $rules ) { $newrules = array(); $page_name = 'mypage'; //basic rule $newrules['(' . $page_name . ')$'] = 'index.php?pagename=$matches[1]'; //search by id $newrules['(' . $page_name . ')/(\d+)$'] = 'index.php?pagename=$matches[1]&id=$matches[2]&search=1'; //url with page included $newrules[(mypage)(/(\w+)-bedrooms)*(/(\w+)-bathrooms)*/([^.]+)/(\d+).html$'] = 'index.php?pagename=$matches[1]&bedrooms=$matches[3]&bathrooms=$matches[5]&query=$matches[6]&page=$matches[7]'; //url with no page $newrules[(mypage)(/(\w+)-bedrooms)*(/(\w+)-bathrooms)*(/([^.]+))*$'] = 'index.php?pagename=$matches[1]&bedrooms=$matches[3]&bathrooms=$matches[5]&query=$matches[7]'; return $newrules + $rules; } add_filter( 'rewrite_rules_array','insert_rewrite_rules' );
  4. Hi, I know this is not a wordpress (wp) forum, but I'm using php regular expressions and I need help. My site is basically a wp plugin that adds a specific search page, so I'm working on providing more SEO friendly urls. I'm trying to match an url like this: http://mysite.com/2-bedrooms/3-bathrooms/mycity/2.html that means the user is looking for a house with 2 beds, 3 baths, placed on mycity and it is requesting the page 2. The regex I'm using is: http://mysite.com/(/(\w+)-bedrooms)*(/(\w+)-bathrooms)*(/(\w+)-city)*/\b([^.]+)\b/(\d+).html but it's not working at all. I'm able to match the ulr withour the page, but when I add the "/2.html" for page 2, wp doesn't understand it and I get a error 404: page not found. All I need is a regex to match with the above given url. Please, give me some hints. Thanks in advance
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.