Hello, I have this rule in my .htaccess file: RedirectMatch 301 ^/browser-sync/browser-sync-client.js /? which I'm using to redirect this: /browser-sync/browser-sync-client.js?v=2.18.13 After searching the web, I found info which said to add "?" to the redirect to remove the query string. Now, the query string is removed, but the ? remains. How can I remove both the query string and the ?. Currently the redirect above will do this: http://somedomain.com/? I want it to just redirect like this: http://somedomain.com/ Thanks You
In Apache 2.4 or newer you can use the QSD (query string discard). RewriteEngine On RewriteCond %{QUERY_STRING} v=(.*) RewriteRule ^/browser-sync/browser-sync-client.js / [R=301,L,QSD] Code (markup):
Hi thanks for this. But unfortunately still having issues. I seem to be having an issue where only root level items are redirecting. For example: This works: RewriteRule ^/oranges.html$ /apples.html? [R=301,L] This does not works: RewriteRule ^/browser-sync/oranges.html$ /apples.html? [R=301,L] Any ides what could the issue?
It should work you only need RewriteEngine On once at the top of your .htaccess You should add the www redirect to the top of your code and remove the L flag (see Removing the Slash)