%postname%
is not a mod_rewrite
rewrite tag. You are going to have to write out the path. mod_rewrite
operates before WordPress, or PHP, gets involved. You don’t have access to any of that functionality.
If your “contact” page– the page named “contact”– has ID 213 you shouldn’t have to do anything to redirect, though. This will happen when you enable pretty permalinks.
You can also redirect using WordPress functionality by doing something like:
function redirect_213() {
if (is_page(213)) {
wp_safe_redirect(wp_safe_redirect(home_url("https://wordpress.stackexchange.com/contact")));
}
}
add_action('template_redirect','redirect_213');
This will probably perform slightly less efficiently than the .htaccess
but you may not notice.
Related Posts:
- 301 Redirects for Changed Permalink Structure & Category Base
- How do I turn off 301 redirecting posts (not canonical)?
- Passing variables through permalink structure
- htaccess or redirect to cloak portion of a link?
- Auto 301 to full post permalink? (using /posts/%post_id%/%postname%)
- Using WP rather than .htaccess to redirect pages/posts
- .htaccess – Redirect duplicated post ended in ‘-number/’ to the same url without the -number/
- WordPress redirection problem after moving to a new server?
- Specific URL Rewriting with parameters in wordpress
- If I change permalink structures, can I use htaccess to permanantly redirect links?
- Redirect parent taxonomy to it’s child
- Need Help Correct Regular Expression Redirect Code
- Custom Permalink
- Redirect a Blogger Page URL to wordpress
- Redirecting all posts after changing URL structure with htaccess
- Redirect all posts permalinks from “.html” to “/”
- WordPress 4.4 old permalink redirect
- Htaccess https 301 problem
- How to use different domains for different blogs hosted in the same host in subdomains with .htaccess
- What causes /pages/ to appear in URI, and how to remove it?
- Some Pemalink problems, probably caused by wrong .htaccess configuration?
- Test site pages go to main site
- Comment author url link is wrong? How to change from authors/ to author/
- change WordPress permalinks and redirect new urls 301
- Custom permalink structure with %postname% in front of domain name
- Configuring Home Page Address
- Can’t access WordPress site in subfolder possibly because of .htaccess redirect from root installation?
- Removed and Reinstalled WordPress, Redirect Broken now
- Why are all pages redirecting to homepage when using custom permalinks?
- .htaccess regex for redirect subdomain to root domain & redirect old permalinks
- 404 posts error after 301 redirection of changed category / tag base
- 301 Redirect posts to newly added categories
- How does WordPress handle permalinks?
- Permalinks to Custom does not work (out of box)
- How can I force WordPress to redirect to canonical permalinks?
- Remove subfolders from URL
- Changing pemalink structure to /%post_id%/%postname%/
- Using only %postname%
- WordPress on VirtualBox – no pretty permalinks
- wordpress permalinks tweeks
- Getting a 500 internal server error ONLY on wp-admin/options-permalink.php
- Redirect old permalinks with Month and name to Post name on new site
- Top level Pages redirecting to homepage!
- After moving from subdirectory to home, home page does not display
- Rewrite my default post URL
- Permalinks: Page Not Found
- Changes to .htaccess not updating the file (old rules still take effect)
- Changed permalink structure. Need help with redirecting old posts
- AWS WordPress Install – pages/posts 404 on restart until updating permalinks
- Permalinks not working with Vagrant
- Only default permalink is working mod_rewrite enabled
- Changing the post date without causing 404 error
- How to redirect to correct pages after permalink structure change
- How do I add /blog/ as a prefix to permalink structure for posts, categories & tags?
- Only plain permalinks working
- How to change old permalink?
- Redirect Uploads Folder to Query Vars in WordPress
- WordPress url ingore permalinks setting [closed]
- flush_rewrite_rules breaks permalinks
- Accessing Subdirectories in WordPress Install
- Empty permalinks settings in .htaccess
- How to rewrite a URL to another rewritten URL without changing the address?
- WordPress 3.1 .htaccess contents keep dissappearing?
- Custom permalinks in WordPress
- Freeze child page URLs so parent permalink changes don’t give 404s?
- How can I make internal anchor links work with WordPress’s permalinks?
- Changing WordPress routing to load the same page for different URLs
- Strange behavior: random HTTP error 500 fixed by visiting Permalinks settings page (htaccess issue with language code)
- how to prefer static page if it exists over wordpress page
- Redirect From Url To Url
- I’ve removed my /author/ slug but it clashes with new and existing pages. Any fixes?
- After cloning WP do a subdirectory, I can’t access it
- Why will Pretty URLs not Work?
- WordPress Page Not Found if Permalink Settings is Postname
- Conditional Permalink based on category?
- Problems with permalinks (.htaccess not working)
- Change author permalink using htaccess?
- All pages load the home page if pretty permalinks are used
- Change url of page according to my requirements in wordpress
- corrupted URLs – can’t leave starting page
- where can i see wordpress automatic redirect History
- Extending page urls without getting a 404
- Cannot publish posts or pages when I change permalink structure
- How to experiment with permalink structure on a select number of posts
- redirect any category in URL to the ID and post-name only – hundreds of pages affected
- Very strange behaviour related to htaccess and custom posts and custom posts substrings (BUG?)
- No Ones Been Able to Override my WordPress Rewrite Rule Issue!
- My permalinks for all pages and posts now include old page titles as parents/categories
- Post redirected to page with same name but DIFFERENT permalink
- Changed Permalinks settings, how do I redirect posts on Nginx?
- Post permalinks go to the home page
- WordPress Category url redirects to subdomain
- LetsEncrypt WordPress on the Raspberry Pi – Nice url’s give 404 with https, http works
- On IIS, stop WordPress from resaving my web.config file when I enter the Permalinks config page
- changing permalink gives 404 error for old links
- Pretty permalinks (again)
- All pages lead to home
- How do you put your own rules into .htaccess?
- Redirecting From An Old Permalink Structure
- Use .htaccess to redirect homepage to its permalink