Redirect sub-pages to parent without changing URL

No, you are on the right track as far as the add_rewrite_rule function is concerned. The generated rewrite rule doesn’t send a 303 header. The problem, in this case, is with your code which can be fixed easily. On this line: add_rewrite_rule(‘^recommendations\/(.*)\/?’, ‘recommendations/’, ‘top’); you are making WordPress to output a modified, custom .htaccess file … Read more

how do i create a specific handler for a url?

You could use the parse_request hook. For example: add_action( ‘parse_request’, function ( $wp ) { // Run your actions only if the current request path is exactly ‘image-generator’ // as in https://example.com/image-generator if the site URL is https://example.com if ( ‘image-generator’ === $wp->request ) { $a = $_GET[‘a’]; $b = $_GET[‘b’]; $etc=”etc”; // … your … Read more

wordpress – load a template based on the URI

I assume that your custom post type windows would map onto /windows/ etc? You can customise the template for individual custom post types via single-posttype.php in your theme, e.g. single-windows.php single-doors.php and single-garages.php WordPress will automatically pick these up You could also use custom page templates, e.g. page-windows.php or custom templates with the right template … Read more

WordPress and VueJS routing problem

This is the default WordPress .htaccess: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress Please add add the following line to it to prevent the default behavior for your custom route. RewriteCond %{REQUEST_URI} !^/my-vue-route/(.+) Like this: … Read more

REST API: No route was found matching the URL and request method

It’s because of how you’ve defined the accepted methods: ‘methods’ => ‘\WP_REST_Server::CREATABLE ‘, You shouldn’t have quotes around it. WP_REST_Server::CREATABLE is a string that equals ‘POST’, but by putting quotes around it you’re literally setting the method as ‘\WP_REST_Server::CREATABLE’, which is not a valid HTTP method. You can see this in the response to the … Read more

Static raw HTML page

Here is what I have in my own .htaccess file that does what you’re looking for: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On Options +FollowSymLinks RewriteBase / RewriteRule ^index\.php$ – [L] RewriteRule ^example.html$ /wp-content/raw/example.html [L] RewriteRule ^download$ /wp-content/raw/download-ebook.html [L] RewriteRule ^thanks$ /wp-content/raw/book-opt-in-thank-you.html [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # … Read more