skip to Main Content

I’m looking for some help. I wanted to redirect the following paramters to another url, how can I make this possible? I have googled alot of other solutions but I fail to make this one work.

https://(www).website.com/reservation#!/confirm?code=a1XapXsCmlaC0
to
https://new-website.com/test/page#!/confirm?code=a1XapXsCmlaC0
Attempted code:
RewriteRule /reservation#!/confirm?code=$ https://test.com/$1

"grep"-ing the code value would make it much easier.

Any help is much appreciated.
Thanks in advance

2

Answers


  1. You may use this redirect rule in your site root .htaccess:

    RewriteEngine On
    
    RewriteCond %{HTTP_HOST} ^(?:www.)?website.com$ [NC]
    RewriteRule ^reservation/?$ https://test.com/test/page [L,NC,R=301]
    

    Query string and fragment i.e. part after # will automatically be forwarded to the new URL.

    Login or Signup to reply.
  2. Based on your shown samples, could you please try following. Where you want to redirect from (www).website.com to new-website.com in url.

    Please make sure you clear your browser cache before testing your URLs.

    RewriteEngine ON
    RewriteCond %{HTTP_HOST} ^(?:www.)?(.*) [NC]
    RewriteRule ^ https://new-%1/test/page#!%{REQUEST_URI} [QSA,NE,R=301,L]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search