The mod_rewrite documentation says:
If you want to delete an existing query string, complete the wildcard with only a question mark.
Although not mentioned in this sentence, the rewrite rule should not use the QSA flag.
How much is the rewrite rule allowed:
RewriteRule ^Register$ index.php?option=com_user&view=register
You probably want this to appear under the rewrite rule to remove the query string. When it matches, the variable %{ENV:REDIRECT_STATUS} set to 200, and mod_rewrite starts the rewrite rules again. The rewrite rule for the query string will match on this second pass if the check that %{ENV:REDIRECT_STATUS} not 200 was not used.
This will display all requests for index.php (with or without a query string) to index.php without a query string, but still allow /Register be processed as /index.php?option=com_user&view=register :
RewriteCond %{ENV:REDIRECT_STATUS} !=200 RewriteRule ^index.php$ index.php? RewriteRule ^Register$ index.php?option=com_user&view=register
Or, if you want to redirect to the error page if the request for index.php has a query string:
RewriteCond %{ENV:REDIRECT_STATUS} !=200 RewriteCond %{QUERY_STRING} !="" RewriteRule ^index.php$ error.php? [R,L] RewriteRule ^Register$ index.php?option=com_user&view=register
But I would just use the F flag:
RewriteCond %{ENV:REDIRECT_STATUS} !=200 RewriteCond %{QUERY_STRING} !="" RewriteRule ^index.php$ - [F,L] RewriteRule ^Register$ index.php?option=com_user&view=register
source share