Assuming state
and city
are variable path segments, so you are essentially redirecting /investments/<one>/<two>/
to /investments/<two>/
then try the following at the top of your .htaccess
file:
# Redirect "/investments/<one>/<two>/" to "/investments/<two>/"
RewriteRule ^(investments)/[^/]+/([^/]+)/$ /$1/$2/ [R=302,L]
If you need any further explanation then just ask in comments.
UPDATE: I’ve added an end-of-string anchor ($
) to the end of the RewriteRule
pattern in the above directive.
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?
- 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
- redirect old pages by .htaccess
- 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
- Setting up WordPress with Custom Permalinks and no .htaccess File?
- Move WordPress to subdirectory, keep ALL URLs
- Custom Taxonomy in Permalink of Post
- WordPress permalinks Yahoo hosting(no .htaccess allowed)
- How can I include a query string with get_permalink
- Changing Permalinks to a Custom Permalink causes a 404 Error [no matter what I do]
- Redirect short-form URL to long-form URL (post_id to post_id + post_name)
- custom naming of search permalink /search/
- Rewriting search permalink
- Rewrite rule never matching
- Stop redirecting to posts not in a category / duplicate slugs
- Redirect user if it’s not logged in
- Random Alphanumeric Key URLs
- Custom url for a single page
- Rewrite-Rules not working on a vhost, everything goes to index.php
- Add a css class to a taxonomy permalink
- What happens when permalink settings are updated?
- Change of permalink structure – redirects in htaccess breaks the archive links
- How can I make my .htaccess file writeable by wp-admin?
- Custom taxonomy rewrite using tax name instead of rewrite slug
- 404 with post name permalinks
- Why does chrome keep downloading a file instead of running the site?
- Permalinks not working
- WordPress 404 in development area
- Does rename of page slugs create 301 redirects from old slug to new (same as for posts)?
- Change in permalink structure made javascript cookie not work correctly
- Change permalinks on move from one site to another
- List / Get post redirects
- Page preview is shown, updating page gives 404 error
- Dynamic Template file for subpage
- How to 301 redirect from one url to another properly
- 301 Redirect for Non-Date Based URL’s
- Passing the JQuery string to Worldpress URL
- An other permalink problem – 404 Error
- WordPress Not Using Template Files After Permalink Update
- Permalinks settings
- 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
- How to redirect RSS feeds to Feedburner and keep pretty permalinks?
- Strange behavior with a redirect loop – involves WPML multi-language plugin
- Redirecting “wrong” but working links to their canonical URL in order to prevent search engine penalties (e.g. /123/ at the end of URLs)
- WordPress not generating .htaccess but tells me that (Permalink structure updated.)
- Arabic permalink redirect to home page
- Getting an ID from a URL, why can WP do this itself, but none of of the functions provided get it right?
- Ignore postname in permalink
- Permalinks – .htaccess
- old permalinks not found
- Remove Parents From Permalink of Hierarchical Taxonomy
- mod-rewrite rules grabs “broken permalinks”, too
- archive by year and category: permalink support doesn’t work on pagination
- Redirect old /%category%/%postname%/ to just /%postname%/
- why wordpress keeps redirecting to old page after deleting it?
- Change permalink structure with post id
- Issue with my links or permalinks
- redirect 301 with special character like WIX site “#!”
- How to rewrite a folder in WordPress?
- WordPress permalink still not working (error or not understood?)
- customize urls displayed by previous_post_link and next_post_link
- .htaccess not working in WordPress
- Pagination is not working, how to trace it properly?
- Problem when i configure permalink
- custom permlink .htaccess file 404 Not Found error
- Files placed in directory with wordpress 404
- 404 not found error on WordPress local host
- Add segment to URL in htaccess
- htaccess strip url