How to configure .htaccess for partial URL redirection in Hubspot?

Hey everyone, I’m stuck with a .htaccess redirect issue. I need to change URLs from our Hubspot site to our CMS. Here’s what I’m trying to do:

I want to redirect:

example.hubspot.com/webapp/signin?param=value&id=12345

to:

mysite.com/webapp/#/signin?param=value&id=12345

The tricky part is keeping all the query parameters intact. I’ve tried this:

RewriteEngine On
RewriteRule ^example.hubspot.com/webapp/signin?* mysite.com/webapp/#/signin?$0 [L,NE,NC,R=301]

But it’s not working. Can anyone help me figure out the correct .htaccess rule for this? I’m pretty new to this stuff, so any advice would be awesome. Thanks!

I’ve dealt with similar redirects before, and there are a couple of things to consider here. First, .htaccess rules typically don’t match against the domain name, so you’ll want to focus on the path. Second, query strings are handled differently.

Here’s what I’d suggest:

RewriteEngine On
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^webapp/signin$ https://mysite.com/webapp/#/signin?%1 [L,R=301,NE]

This should capture the entire query string and append it to your new URL. The NE flag ensures special characters aren’t escaped.

Remember, you’ll need mod_rewrite enabled on your server for this to work. Also, clear your browser cache when testing redirects, as old redirects can sometimes stick around and cause confusion.

Hope this helps! Let me know if you run into any issues implementing it.