define( 'AMP_QUERY_VAR', apply_filters( 'amp_query_var', 'amp' ) ); add_rewrite_endpoint( AMP_QUERY_VAR, EP_ALL ); Here is the code. It worked on all pages except posts. If you write amp then returns to the same page of the post. If you set remove_filter('template_redirect', 'redirect_canonical'); then with the link http://site.com/post-name/amp/ It gives 404 If instead of EP_ALL put EP_PERMALINK then everything works. What kind of strange behavior?