This should work for you-
function wpse28906_rewrites_init(){
add_rewrite_rule(
'mypage/([^/]+)/?$',
'index.php?pagename=mypage&myslug=$matches[1]',
'top' );
}
add_action( 'init', 'wpse28906_rewrites_init' );
function wpse28906_query_vars( $query_vars ){
$query_vars[] = 'myslug';
return $query_vars;
}
add_filter( 'query_vars', 'wpse28906_query_vars' );
You can then use get_query_var( 'myslug' )
in your template to get your slug value. Don’t forget to flush your rewrite rules after adding this by visiting the permalinks settings page.
Related Posts:
- Setting up WordPress with Custom Permalinks and no .htaccess File?
- Does WordPress Change the .htaccess File When Updating?
- Move WordPress to subdirectory, keep ALL URLs
- Permalinks to Custom does not work (out of box)
- WordPress permalinks Yahoo hosting(no .htaccess allowed)
- How do I turn off 301 redirecting posts (not canonical)?
- Permalink Issues by Installing WordPress in Subdirectory / Subfolder
- WordPress on a subdirectory of Laravel – WordPress pretty permalinks inner page shows laravel
- How to map permalinks with accented letters to sanitized slugs?
- Changing Permalinks to a Custom Permalink causes a 404 Error [no matter what I do]
- WordPress overrides the GET variables, (page_id) set in HTACCESS
- custom naming of search permalink /search/
- Changing URL from /%postname%/%post_id to /%category%/%postname%/%post_id%
- removed index.php now all pages 404
- Rewriting search permalink
- removing index.php IIS 7.5 webconfig
- Rewrite rule never matching
- Redirect user if it’s not logged in
- Custom url for a single page
- Using WP rather than .htaccess to redirect pages/posts
- What happens when permalink settings are updated?
- WordPress redirection problem after moving to a new server?
- Change of permalink structure – redirects in htaccess breaks the archive links
- WP Site in subdirectory Joomla! Site – Permalinks not working
- Rewrite my default post URL
- How can I make my .htaccess file writeable by wp-admin?
- 404 with post name permalinks
- .htaccess file missing from WordPress install directory
- Why does chrome keep downloading a file instead of running the site?
- Permalinks: Page Not Found
- How to protect htaccess so it can’t be overwritten?
- Permalinks not working
- WordPress 404 in development area
- Need Help Correct Regular Expression Redirect Code
- Permalinks settings page blank
- 301 Redirects Result in 404 for WordPress Search Query Strings
- After updating to 4.8 permalinks will not work (all 404)
- Custom Permalink
- Change in permalink structure made javascript cookie not work correctly
- Only default permalink is working mod_rewrite enabled
- How do I add /blog/ as a prefix to permalink structure for posts, categories & tags?
- WordPress Sub domain
- Page preview is shown, updating page gives 404 error
- WordPress url ingore permalinks setting [closed]
- Redirect a Blogger Page URL to wordpress
- URL rewriting: removing the site’s basename for a specific category
- Redirecting all posts after changing URL structure with htaccess
- Redirect all posts permalinks from “.html” to “/”
- Htaccess https 301 problem
- An other permalink problem – 404 Error
- WordPress Not Using Template Files After Permalink Update
- Allow Permalinks to Work with and without Hyphens
- How to prevent WP overwriting my custom htaccess rewrites?
- mod-rewrite exception? keep #hash in matching urls?
- .htaccess rewriterule being ignored – tyring to remove dates from WP posts
- Permalink for specific page name
- Some Pemalink problems, probably caused by wrong .htaccess configuration?
- Comment author url link is wrong? How to change from authors/ to author/
- How to redirect RSS feeds to Feedburner and keep pretty permalinks?
- WordPress not generating .htaccess but tells me that (Permalink structure updated.)
- Ignore postname in permalink
- Permalinks – .htaccess
- Custom permalink structure with %postname% in front of domain name
- Configuring Home Page Address
- How Can I Use a Custom AccessFileName?
- xammp server permalink by postname not working
- Custom permalink structure only saves with index.php inserted
- old permalinks not found
- What would cause a 500 Server Error with permalinks turned OFF?
- mod-rewrite rules grabs “broken permalinks”, too
- .htaccess to redirect to a wp page
- Got 404 error when changed siteurl via DB in WordPress
- All files in public_html, Cannot launch WordPress site via wp-admin
- wordpress admin panel loop on nginx
- WordPress All pages but home simply read “hello”
- Issue with my links or permalinks
- Page permalink redirects to home page
- WordPress pages break with custom permalink settings (theme directory not output)
- How to rewrite a folder in WordPress?
- Removing or hiding slug/permalink from htaccess
- Fresh wordpress installation in sub-directory not accessible
- When using number in url it is redircting to same page but when using character it redirects to 404
- Folder Name and Category Name WordPress
- Once redirected by Rewrite rules, how can WordPress know the page?
- customize urls displayed by previous_post_link and next_post_link
- Removed and Reinstalled WordPress, Redirect Broken now
- .htaccess not working in WordPress
- Problem when i configure permalink
- redirect old pages by .htaccess
- custom permlink .htaccess file 404 Not Found error
- Why are all pages redirecting to homepage when using custom permalinks?
- Files placed in directory with wordpress 404
- 404 not found error on WordPress local host
- .htaccess regex for redirect subdomain to root domain & redirect old permalinks
- 404 posts error after 301 redirection of changed category / tag base
- Add segment to URL in htaccess
- htaccess strip url
- 301 Redirect posts to newly added categories
- Standard Htaccess directives disappear by themselves
- How to use ‘blogs.dir’ as media upload instead of ‘uploads’ directory in WordPress multisite setup