I’ve not tried external rules, but you can achieve that with an internal rewrite and pagename
:
function wpd_page_rewrite(){
add_rewrite_rule(
'^anothername/([^/]*)/?',
'index.php?pagename=$matches[1]',
'top'
);
}
add_action( 'init', 'wpd_page_rewrite' );
For parent/child pages you have to set pagename
to the parent/child path, page/pagename
, or you can also use page_id
and use the page’s ID.
EDIT – note that you have to flush rewrite rules after adding new ones. a quick way to do this during testing is to visit the permalinks settings page.
Related Posts:
- Passing and retrieving query vars in wordpress
- Pretty permalinks for search results with extra query var
- How to remove dates from existing permalinks?
- Getting the Site URL Including the Front Base
- Using $_GET variables in the URL?
- Including category-base in a post permalink results in 404
- WordPress thinks my custom route is a 404
- Date based URLs for custom posts and pagination
- Update URL Snippet to Canonical Permalink URL
- How to prevent the default home rewrite to a static page
- “.#[random-char-string]” being inserted at end of URLs
- URL Rewrite + Page + Custom Post Type = Unusual Redirect
- Pretty Permalinks
- Remove parent slug for child pages
- How to remove the index.php in the url?
- How can I Rewrite a ‘page’ URL based on query string parameters?
- custom naming of search permalink /search/
- Rewrite user profile URL to be human friendly
- Random Alphanumeric Key URLs
- Using WP rather than .htaccess to redirect pages/posts
- Rewrite URL for results of a custom WP_Query
- rewrite_rule for custom post type doesn’t affect get_permalink
- Add ‘articles’ prefix before blog posts url without affecting pagination
- custom permalink/shortlink with base62 encoded post ID
- Change permalinks with ACF values
- template_include not loading -instead goes to index.php
- Incorrect 404 for pages when using permalink, a static front page, and posts page
- add new permalink structure from dynamic page
- WordPress not respecting template hierarchy (fetches index.php instead of single.php or page.php)
- How to improve WordPress security by hiding non public facing files?
- Call to a member function add_rule() on a non-object
- Custom taxonomy rewrite using tax name instead of rewrite slug
- Why does chrome keep downloading a file instead of running the site?
- How can I add a page’s ID to its permalink using WP_Rewrite?
- Why is add_rewrite_endpoint incompatible with /%category%/%postname%/ permalink structure?
- Re-write specific custom post type category URL to go to another page
- Is it possible to keep all special letters for foreign languages in slug as in title?
- Change blog segment of URL
- add_rewrite_rule not working for me
- Using WP Rewrite, but just not “getting it”
- Share same Slug for a Custom Post Type and 2 Taxonomies
- Rewrite CPT permalinks and include WPML language
- Redirect a Blogger Page URL to wordpress
- Custom permalink leads to index page
- Mirror content based on URL slug
- How to change hierarchical page permalinks to be flat
- IIS 7 Rewrite with parent categories
- Do WordPress Permalinks Refer to a Lookup Table in the Database?
- Passing the JQuery string to Worldpress URL
- Permalinks only for posts
- mod-rewrite exception? keep #hash in matching urls?
- Format HTTP links
- Change directory url to be same as page permalink?
- Visiting posts results in 404 errors after host migration
- Order custom post type posts by custom field with pretty URL
- Show category name in the post URL only for specific categories
- Adding URL prefix for foreign language support
- 404 permalink errors on Pages only
- Redirecting “wrong” but working links to their canonical URL in order to prevent search engine penalties (e.g. /123/ at the end of URLs)
- help to remove last trailing slash using add_rewrite_rule
- Change permalink to attachment
- Custom permalink structure with %postname% in front of domain name
- How can I set up a secondary permalink structure?
- Problems with permalinks (.htaccess not working)
- WP-e-commerce (getshopped) – Annoying permalink issue [closed]
- Subdomains pointing to a permalink URL
- How to Use metada Value in Url and is it possible? [duplicate]
- How do I rewrite attachment urls when permalink structure contains %category%?
- IIS7.5 URL rewrite pboblem on index page
- Custom child page permalink
- Can I change the URL structure for a CPT only?
- Safest way to create a custom permalink
- How to set add_query_arg properly for home page?
- Creating an alternate path for a page
- corrupted URLs – can’t leave starting page
- How to change URL from /%postname%/ to custom-name/%category%/%year%/%monthnum%/%day%/%postname%/
- Create different permalinks for same post
- WordPress Attachment Page URL Rewrite!
- Permalink not changing according to post type
- WP permalink working, but why content doesn’t display
- WordPress Multisite ABSPATH and get_home_path() to check for htaccess or web.config file
- Flushing rewrite rules enables to see an article, but I didnt change anything
- Redirect page to homepage, keeping URL
- How can I put WordPress in a directory but keep just the home page at the domain root?
- Updates all internal links on permalink update
- how to have same rewrite rules for 2 different post type?
- Permalink structure /page/page/cpt-post gives 404 with pagination
- What permastrusture tags are generated out of the box right after creating custom post types and taxonomies?
- Rewrite posts url as they’re all children of a page
- Multiple Permalink Patterns for one page
- How to rewrite a folder in WordPress?
- Folder Name and Category Name WordPress
- WordPress permalink still not working (error or not understood?)
- How to change pagination base from slash to query form?
- How to shorten the Permalink after WP>WP blog import?
- how to create several url aliases for a page
- Single product link in woocomerce
- URL issues with WordPress
- Add additional URL variations for a Post
- How to make my custom permalink pull up the correct post