Query string redirect inside htaccess file?

timb551
timb551 used Ask the Experts™
on
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
David FavorFractional CTO
Distinguished Expert 2018

Commented:
No difference stands out clearly between the 2x URLS.

State the one change you're trying to accomplish, as they both look identical to me... except for the hostname...

Maybe verify if all your trying to accomplish is a redirect a new hostname, passing all query parameters intact... and stripping off the /survey link too.
Fractional CTO
Distinguished Expert 2018
Commented:
Maybe something like this...

      RewriteEngine on
      RewriteRule ^survey/?$ https://survey.domain.co.uk/?%{QUERY_STRING} [NC,L,R=302]

Open in new window


You might have to massage this a bit, as it's off the top of my head.

Big Note: Be sure to use 302s for all redirects. Avoid 301s like the plague. If you make a typo in your redirect rule + use 301s, there is never any way to effect previous visitors, as 301s (by definition) cache forever in browsers.

Using 302s is the only way to change a redirect over time + have the changes work for past visitors + new visitors.

Using 301s has resulted in many a small fortune being lost.
timb551IT Manager

Author

Commented:
Hi David

the change is from the www subdomain to a survey subdomain.

ill try the suggestion above, thanks
timb551IT Manager

Author

Commented:
Thanks David, that worked perfectly.
David FavorFractional CTO
Distinguished Expert 2018

Commented:
Excellent!

You're welcome!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial