Email-Icon Created with Sketch. Group 3 Created with Sketch. Domains-SVG-Box Created with Sketch. Domains-SVG-Box Created with Sketch. Domains-SVG-Box Created with Sketch. Hosting-SVG-Box Created with Sketch. Hosting-SVG-Box Created with Sketch. Icon-Internet Created with Sketch. Hosting-SVG-Box Created with Sketch. Icon-Internet Created with Sketch. Icon-Internet Created with Sketch. Trust Pilot Stars Created with Sketch. 1-5-million Created with Sketch. Control-panel-Icon Created with Sketch. WSB-Brush Created with Sketch. WSB-Brush Created with Sketch. WSB-Brush Created with Sketch. Email-Icon Created with Sketch. Email-Icon Created with Sketch. Email-Icon Created with Sketch. Email-Icon Created with Sketch. Icon-ECommerce-Seperator Created with Sketch. Icon-ECommerce-Seperator Created with Sketch. Icon-ECommerce-Seperator Created with Sketch. icon-slider-next Created with Sketch. icon-slider-prev Created with Sketch. Webmail-icon Created with Sketch. heart Created with Sketch. Open-24-7 Created with Sketch. open24 Created with Sketch. 24 7 trusted Created with Sketch. Fill 1 Created with Sketch.

How can I redirect a visitor to another page?

You can use .htaccess to automatically redirect a visitor to another location, for example when you have a new website, or if your site is still under construction.

In this guide you can find a description of some of the most commonly used functions and how to implement them on your web space at One.com.


Redirect 301
Redirect to www.yourdomain.com
Redirect to yourdomain.com
Rewrite everything to HTTPS
Tip: If you want to redirect your whole website to another domain or ip-address, we recommend using DNS instead. Check out our guide on how to manage your DNS settings.

Redirect 301

You can permanently redirect your visitors to another location, this is called Redirect 301.

The number 301 stands for the http status code. Adding the number 301, tells search engines that the address has permanently moved to another location, consequently your page ranking will also be moved.


Redirect 301 /oldpage.html http://www.one-example.com/newpage.html

Replace /oldpage.html with the current page name and http://www.one-example.com/newpage.html with the new location. Make sure all text is on one line.

Note: In some cases you might want to redirect your visitors only temporarily, for example to an under construction page. In that case it is better to use another code, use number 307 instead of 301.

Redirect to www.yourdomain.com

You might want to do this to improve your search engine ranking. Search engines recognize www.yourdomain.com and yourdomain.com as two different pages, it is better if only one page is used.


#Rewrite to domain with www RewriteEngine On RewriteCond %{HTTP_HOST} !^(.+\.)([a-zA-Z0-9-]+\.([a-z]{2,4})|co\.uk|me\.uk|org\.uk|priv\.no)$ RewriteCond %{HTTP_HOST} ([a-zA-Z0-9-]+\.([a-z]{2,4})|co\.uk|me\.uk|org\.uk|priv\.no)$ RewriteRule ^(.*)$ http://www.%1/ [L,QSA,R=301]

Redirect to yourdomain.com

Similar to redirecting to www, but the other way around. It serves the same purpose.


#Rewrite to domain without www RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.(.*) RewriteRule ^(.*) http://%1/$1 [QSA,L,R=301]

Rewrite everything to HTTPS

If you have activated SSL on your web space you can rewrite all traffic to https://. That way you can make sure that your visitors only use a secure connection. If you only want to redirect to https:// in certain folders on your site, you can add the .htaccess file to that specific folder.


#Rewrite everything to https RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Related articles:

What is .htaccess?
How can I protect my website with a password?