Just use this rewrite rule in your htaccess file,
it will strip all query strings.
RewriteRule ^(.*) /$1? [R=301,L]
to allow more rules to follow use this instead
RewriteRule ^(.*) /$1? [R=301]
remove 301 like this
RewriteRule ^(.*) /$1? [NE,L]
and refer the correct url for search engines.
without 301 you will need to make a canonical link
pointing to the correct url.
if you are rewriting the URL for SEO then a better
way might be to block search engines from crawling
pages with querry strings by adding this to your
robots txt file.
Disallow: /site/city-page/?*
This rule presumes you site directory is e.g /site/city-page/
Hope this helps
Related Posts:
- Adding rewrite endpoint breaks static front page
- Unique URL Every Time
- Rewrite default post type
- Rewrite Rules for Multiple (more than 2) Taxonomies
- How to add dot(“.”) in post slug
- add_rewrite_rule not loading correct page nor getting variables
- Using plus (+) sign instead of space (-) in WordPress URL
- Add language/country code to each possible URL
- Google is indexing wordpress attachment pages
- SEO Friendly URLs for my plugin categories
- How to create a specific frontend URL (not a Page) from a theme or plugin?
- WordPress URL rewrite regex
- WordPress keeps writing rewrite rules to .htaccess
- custom template for custom url
- page is not redirecting
- Combine Multiple Categories Into One URL Slug
- Multilingual theme: Changing locale based on URL
- Custom rewrite rule for backend/admin?
- How to have multiple rewrite endpoints in the same URL?
- add_rewrite_rule is not taking effect in WordPress? .htaccess file doesn’t update
- Author Profile URL
- Remove all categories from URL
- change default ‘post’ slug with register_post_type_args
- Add specific word to default page permalink
- Removing “category” from URLs then “add_endpoint()” won’t work…
- Is it possible to generate an alternate structure for multi-tag urls?
- Use single-site install and map entities to subdomains
- Custom query_vars and parse_request on wp-admin
- WordPress SSL (https) is not working with custom permalink
- How do I change attachment slug from name to id
- How to define a callback for an URI?
- NextGEN Gallery Lightbox – Social Share URL Redirect
- WordPress .htaccess blocks mine?
- My WP_options db rewrite_rules Does Not Work
- Rewrite Preview URL to include index.php
- Custom rewrite_rules – only pass numbers and not alphabetic characters
- How can I dynamically generate an image with a static image URL?
- Rewrite wp-login.php URLS to static pages?
- How to access custom pages
- How to create rewrite endpoints it in author.php?
- Changed pagination URLS to use p= instead of paged=
- React Router with WordPress
- joomla to wordpress migration and 404 errors issues [closed]
- How can I change the permalink of a translated home page?
- How to write Rewrite rule for same path using Rewrite API?
- Add word to permalink when custom field has a value
- simple add_rewrite_rule added, refuses to work
- 301 Redirect all posts urls from .html to / (without .html)
- Custom rewrite after the default term link URL
- How can I reduce the number of rewrite rules?
- Create a page that can be used for different URLs
- Capturing /page-name/[0-99999] in both template and number
- custom wordpress rewrite
- Keep requested/entered url with add_rewrite_rule
- Get wordpress installation folder
- Disable WordPress from changing URL slug when post is published
- Rewrite Rule for homepage not working correctly
- WordPress .htaccess ignore path and subsequent .htaccess files in subfolders
- Adding Rewrite URL for Base + Children Separately
- How to customize sub-URLs in a wordpress website (.htaccess)
- Rewriting a date hierarchy into a ‘yyyy-mm-dd’ slug
- URL rewrite( I think? )
- Help with WordPress custom url rewriting?
- Page not found: Custom search form with a custom search page
- Make the home page’s slug visible in the browser’s URL bar
- WordPress how to prevent URL encoding in URL of taxonomy terms
- loading images, css and fonts from site url
- Query vars to return the homepage
- dynamic URL rewrite
- How can I add a vanity URL for admin-ajax.php Calls?
- Remove part from dynamic url and redirect
- Rewrite rule can’t get the ID from rewrited
- How to Update / Change URL when Popup Modal Loads?
- How wordpress core include search.php with $_GET[‘s’]?
- Pretty URL via Rewrite
- Dynamic Content w/ geolocation in WP?
- WordPress numeric (yearly) page names / disable yearly archives
- Routing in WordPress
- url redirect none www to www
- Stop wordpress from prettify URL
- Moved WordPress to Subdirectory, still hijacking requests to files outside of its directory
- How to remove Base URL Duplication?
- Rewrite URL query string for all pages
- ModRewrite not working properly
- Need help with custom rewrite rule
- WordPress doesn’t remember my custom rewrite rule
- Custom urls in WordPress involving page slugs
- Relative URL filtering
- how to change some of the rules in the database
- get_permalink is getting old rewrite rule
- Rewriting URL does not automatically log me in
- Custom Rewrite for Profiles
- Pagination posts. Url format
- how rewrite is working in wordpress
- How to prevent URL-modification when page title contains digits only?
- How do I display a friendly URL link in the frontend?
- rewriting an Url
- WordPress Post url encoding problem
- Please give me the rewrite rules for my ugly urls
- Rewrite rule to simulate page hierarchy results in 404