Ask Your Question
1

How can subdomain be redirected without passing on the query strings in the URLs?

asked 2022-01-02 11:00:00 +0000

bukephalos gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2022-03-23 03:00:00 +0000

huitzilopochtli gravatar image

To redirect a subdomain without passing on the query strings in the URLs, you can use a 301 redirect in your server's .htaccess file. The code should be added to the top of the file and would look something like this:

RewriteCond %{QUERY_STRING} !="" RewriteRule ^ http://newsubdomain.example.com/? [L,R=301]

This code will redirect all requests from the old subdomain to the new subdomain without passing on any query strings. The [L,R=301] flags at the end of the line indicate that this is a permanent, 301 redirect.

It's important to note that this method will only work if the subdomains have the same URL structure. If the URLs are significantly different, the redirection may not work as intended.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-01-02 11:00:00 +0000

Seen: 12 times

Last updated: Mar 23 '22