I'm not too familiar with regular expressions and I'm having trouble achieving what I want.
The website I'm working on used to have a wordpress blog on it and there are existing links on the internet pointing to http://www.website.com/?p=(random number).
The current code I have right now doesn't seem to work:
RewriteCond %{QUERY_STRING} p=(.*)
RewriteRule http://www.website.com/ [R=301,L]
In fact if there is a way to remove any kind of query string for the index page, that would be even better.
Thanks in advance.
If you want to remove all query strings regardless
RewriteCond %{QUERY_STRING} .
RewriteRule ^$ /? [R,L]
This tests if there is any query string .
and then redirects to the home page without query string /?
.
Never test with 301
enabled, see this answer Tips for debugging .htaccess rewrite rules for details.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.