The old domain is:
www.example.com/newspage.asp?m=4&y=2015
and I need that URL, as well as that URL with different query paramaters to go to:
example.com/news
.
So, you are also changing the host with this redirect (www subdomain to bare domain)? Otherwise, it just looks like you can ignore the query string. This is relatively trivial to do with mod_rewrite. The following directives would need to go near the top of your .htaccess
file, before the WordPress front controller.
RewriteRule ^newspage\.asp$ http://example.com/news? [R=301,L]
This matches any query string.
The ?
on the end of the RewriteRule
substitution removes the query string from the request. Otherwise, it gets passed through to the target URL. Alternatively, on Apache 2.4+, you can use the QSD
(Query String Discard) flag instead.
Related Posts:
- Rewrite /?rest_route=/ link to /wp-json/ without changing default permalink structure in apache
- index.php not loading in main folder of wordpress
- Redirect from different port to subdomain – htaccess
- WordPress 404 on Subdomain
- Only expose routes with prefix /wp-json on WordPress using Apache
- What’s the opposite of required valid user in .htaccess authentication
- How can i redirect one url to another url using .htaccess or add_rewrite_rule
- Override htacces rule only for specific directory
- Restrict uploaded files into a custom folder to logged in users by htaccess: looking for Nginx – not only Apache – solution
- How do I test to ensure that my wp-config file is protected?
- .htaccess Security Header Rules
- mod_rewrite loop, redirecting http to https on certain section of wordpress blog
- .htaccess in subdir gets ignored by WordPress’ own .htaccess in /
- Directing subdomain to main domain and keeping the subdomain format with .htaccess
- WordPress – Promoting A Dev Build In A Subdirectory To Production / Root Directory
- Does WP suppresses .htaccess if permalinks are disabled?
- fix 302 redirection error on https
- Access sub-domain when root public_html is protected with .htaccess password
- Accepting special characters in querystring
- WordPress permalinks confusion
- Configure .htaccess to have a WordPress single site installation with all subdomains pointing to the same pages?
- Unable leverage Browser Caching on AWS Bitnami stack (Apache) through W3TC and Cloudfront CDN
- How to move wordpress website from hosting account to localhost
- How to block wordpress admin by htaccess
- I can access subdirectory, but not files within it
- WordPress redirection
- How To Add CSP frame ancestors in WordPress Website? [closed]
- Subfolder install not working
- Browser Caching .htaccess
- Hardening WordPress – how to set .htaccess permissions?
- Avoid duplicate content on pretty URLs with htaccess
- How can I use an .htaccess file in Nginx?
- .htaccess redirect http to https
- Redirect vs RedirectMatch
- How to automatically redirect HTTP to HTTPS on Apache servers?
- htaccess – Redirect to subfolder without changing browser URL
- How do I disable directory browsing?
- Https to http redirect using htaccess
- Getting a 500 Internal Server Error on Laravel 5+ Ubuntu 14.04
- How to remove index.php from WordPress site URL
- .htaccess: Invalid command ‘RewriteEngine’, perhaps misspelled or defined by a module not included in the server configuration
- Redirect old php link to wordpress link in .htaccess
- Redirect old php link to wordpress link in .htaccess
- Cant login to wp-admin (redirecting to homepage), But CAN login to wp-login.php
- Cant login to wp-admin (redirecting to homepage), But CAN login to wp-login.php
- Best collection of code for your .htaccess file [closed]
- Default .htaccess file for WordPress?
- Which one does WordPress prioritize when it comes to php.ini, wp-config and .htaccess?
- Improve wordpress security by hiding non public resources
- WordPress site hacked. Has .htaccess been hacked?
- Does this .htaccess security setting really work?
- Use subdomain for certain urls
- htaccess problem after saving Settings
- Multisite htaccess on localhost with WP as an SVN external?
- Stop WordPress and Plugins from Overwriting .htaccess
- File and directory permissions
- htaccess disable WordPress rewrite rules for folder and its contents
- htaccess rewrite conflict with wordpress rules and ssl
- htaccess https redirect from www to non-www
- Htaccess for Wordpess set on single subdomain
- adding rewrite rules in .htaccess
- .htaccess and 500 error, extra character added
- Name-based virtual host configuration in Apache seems to cause a “500 Internal Server Error”
- Place static HTML files in path below WordPress page
- WordPress Multisite – Multiple subfolders for blogs
- Static raw HTML page
- WordPress + Magento .htaccess ReWriteRule Issue (www vs. non-www)
- Plugin to edit htaccess file
- htaccess rewrite for author query string when WP is in subfolder
- Why “Settings->Permalinks” creates .htaccess file on nginx server?
- .htaccess for wordpress inside another wordpress install
- .htaccess file redirecting to parent directory
- WordPress in sub directory wp-admin problem
- Blog.php or how to display recent posts?
- Globally force SSL on all pages
- Serve apache 404 for missing assets rather then wp 404 template WP_Rewrites
- Isolating WordPress to a subfolder
- Remove year and month in URL using .htaccess
- Admin-Ajax.php, SSL, Non-SSL
- Error 101 after upgrading WordPress
- How disable SSL redirect for specific URL?
- WordPress site displaying 404 for any page apart from index
- Why does the header set X-Robots-Tag apply to all pages?
- Permalinks not working on second wordpress installed in a subdirect
- How to avoid wordpress permalink rules to inherit in a sub-folder
- Error:406 not acceptable
- Unable to access WP admin
- .htaccess Rewrite URL WordPress
- Move wordpress to folder without changing urls
- Rewrite rule not working
- A plugin changes my .htaccess file and I can’t access httpd.conf as that’s a shared server
- Cant block wordpress readme files
- Change wp-content without changing the name of the folder
- 404/500 error on /wp-json
- WordPress keeps deleting .htaccess file
- WordPress multisite causing Error 101 (net::ERR_CONNECTION_RESET): Unknown error [duplicate]
- Correct htaccess to display page while also passing in GET parameters
- What is the role of .htaccess file in WordPress?
- Using “wordpress_logged_in” to restrict direct access to uploads folder in 2021
- Does WP Have a Function To Generate .htaccess RewriteCond?