This is essentially the same page, I just need to redirect from a url that uses the GET parameter to a url without this parameter.
RewriteCond %{QUERY_STRING} ^category=([^&]+)&key=news-category$
RewriteRule ^news/$ /news/%1/? [R=301,L]
This is essentially the same page, I just need to redirect from a url that uses the GET parameter to a url without this parameter.
RewriteCond %{QUERY_STRING} ^category=([^&]+)&key=news-category$
RewriteRule ^news/$ /news/%1/? [R=301,L]
Copyright © 2021 Jogjafile Inc.
This rule should only apply to direct requests from the client, not rewritten requests (by other rules) - which is probably what's causing the redirect loop. You need an additional condition (
RewriteConddirective) on the above rule. For example:This rule should also appear early on in the
.htaccessfile, before other rewrites.The
REDIRECT_STATUSenvironment variable is empty on the initial request and set to200(as in "200 OK" HTTP status) after the later rewrite.Also, if you are on Apache 2.4, consider using the
QSD(Query String Discard) instead of appending an empty query string (in order to remove the original query string). TheQSDflag completely removes the query string, whereas the trailing?sets an empty query string which relies on the user-agent (browser) removing the trailing?in the redirected request.Clear your browser cache before testing and test with 302 (temp) redirects to avoid potential caching issues.
Aside: Make sure you are linking directly to the "pretty" URL. This "redirect" directive should not be processed at all under normal conditions (it's only required to preserve SEO when changing an existing URL structure).