Loading

Redirect to other page or domain without changing url

Redirect to other page or domain without changing url

When you are about to hide some sensitive information containing in url from user. It will become difficult particularly when redirecting to other page or external domain with url query parameters. But using .htaccess file it is easier and takes just few minutes.

Redirect to other page or domain using .htaccess file

If you are using linux or windows os with apache server it will be very easy to hide url while making proper page or url redirection. Open your .htaccess file from your domain root and add the following snippet.

RewriteEngine On #do not add this line if its already present in your htaccess file
RewriteCond %{REQUEST_URI} ^/your-page
RewriteRule ^(.*)$ https://otherdomain.tld/new-page$ [P]

If you want to redirect a domain to other domain or page

RewriteEngine On #do not add this line if its already present in your htaccess file
RewriteCond %{HTTP_HOST} ^yourdomain.com
RewriteRule ^(.*)$ https://otherdomain.tld/new-page$ [P]

NOTE:

Most web hosts do not allow you to use proxy redirection, if not enabled mod proxy you will get 500 internal error