Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    The purpose of add_rewrite_rule() is to identify an URL like example.com/europe/about/ via a regexp and rewrite it to example.com/index.php?name=about&region=europe. Then your code can get the passed region from $_GET['region'] and act accordingly. It’s the best solution for custom URLs, it will work when done correctly.

    One reason for failure would be if another rule is matched before yours. You generally want to pass the $after parm in add_rewrite_rule() as “top” to avoid this. Another reason for failure is neglecting to visit the permalinks settings screen after changing rules. Doing so causes the current rules to be flushed.

Viewing 1 replies (of 1 total)
  • The topic ‘Custom URL’ is closed to new replies.