How can I rewrite a Wordpress URL such that, if I have a page A hosted at www.domain.com/A, Wordpress also displays that page for www.domain.com/A/ABC, www.domain.com/A/ABCDEF, etc.? I understand that this probably isn't a good idea in general. I have a very specific use case for this. My testing server runs Ubuntu while the live server runs Windows Server 2003, both sites are on Apache.
What I've tried:
-
Modifying .htaccess directly:
RewriteRule A/?.* A/
(I attempted to debug why this didn't work by turning on RewriteLog in my Apache server configuration. I found out that all rewrites end up at Wordpress's index.php anyway, so I figured it might be more appropriate to use Wordpress's rewrite tools for this.)
-
Using WP_Rewrite (in functions.php):
function A_rewrite( $wp_rewrite ) { $wp_rewrite->rules["A/?.*"] = "A/"; return $wp_rewrite->rules; } add_filter('generate_rewrite_rules', 'A_rewrite');
Both of these approaches failed to rewrite the URL, i.e. the request still went to /A/ABCD, yielding a 404.
Would greatly appreciate guidance on what I did wrong with either of these approaches, or a better solution.