1

I am looking to create a redirection flow-through on a website that can take a URL such as:

https://example.com/go/asset?tag=1234567

And can redirect it to:

https://newexample.com?asset=1234567

I think I might be close, but can't seem to get it working:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} /go/asset$
RewriteCond %{QUERY_STRING} tag=\d{7}
RewriteRule ^(.*)$ https://newexample.com?asset=%1 [R=301,L]
</IfModule>

I saw a few similar examples that have informed my attempt, but nothing specific to my use case. Many thanks in advance!

1 Answer 1

1

I was able to figure this out with some additional testing, here's the working redirect:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} ^.*(\basset\b=(\d{7}))$
RewriteRule ^(.*)$ https://newexample.com?asset=%2 [R=302,L]
</IfModule>

This testing tool was particularly helpful:

https://htaccess.madewithlove.be/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.