add rewrite rules for a non-wordpress php file
-
I have a file called getpage.php that I want to access with a url like https://www.mysite.com/getpage/ instead of https://www.mysite.com/wp-content/custom-pages/getpage.php.
when I use the following code as a plugin and navigate to https://www.mysite.com/getpage/ I get redirected to the homepage instead of the page I’m trying to request.
function kk_rewrite_rules( $wp_rewrite ){ $new_rules = array('^getpage/?$' => 'wp-content/custom-pages/getpage.php'); // Add the new rewrite rule into the top of the global rules array $wp_rewrite->rules = $new_rules + $wp_rewrite->rules; }
Any ideas? I think what might be happening is that wordpress makes everything go through index.php so if it’s not a $_GET request like index.php?mypage=getpage then I can’t use wp_rewrite to redirect to the proper page.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘add rewrite rules for a non-wordpress php file’ is closed to new replies.