Redirect Url With Query String To Ca Certain Page

- 1 answer

i have URLs which look like this:

Now i want to redirect URLs with the certain query "callback=confirm_searchagent". I tryed to do this via .htaccess and used the following code

 RewriteCond %{QUERY_STRING} ^callback=(.*)$
 RewriteRule ^(.*)$ /immobilien/ [R=301,L]

The code did not change anything, no redirection, no errors.

i hope somebody can help me with this?



You can use this :

 RewriteCond %{QUERY_STRING} callback=(.*)
 RewriteRule ^(.*)$ /immobilien/? [R=301,L]

I removed the ^ from your condition regex as it was looking for a query string that starts with this spacific key. Also I added a ? at the end of the rule to remove query strings from the new redirected URL. You can remove this ? if you want query string appended.