Home » Htaccess Tools » Questions regarding htaccess » how to do redirect and standardise URL at the same time
how to do redirect and standardise URL at the same time [message #562] Tue, 12 September 2006 05:06 Go to next message
g123  is currently offline g123
Messages: 1
Registered: September 2006
Hi, I am very new to htaccess and in need of a solution to my problem ASAP. I need to create a htaccess file that does two things for me;

1. it needs to redirect from http tp https protocol.
2. it also needs to standardise the URL web address so it always includes 'www' in the URL.

I found some solutions (listed below) that solve each of these situations, but I need one htaccess file that does both and that is where I am having problem. The solutions I've found are as follow:

--------------------------------------------------------------------
// Redirecting from http to https protocol

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
----------------------------------------------------------------------
// standaridise URL so it alwaysinlcude 'www'


RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
// ---------------------------------------------------------------------

Again how do I write one htaccess file that covers both situations?

thanks
how to do redirect and standardise URL at the same time [message #577] Tue, 19 September 2006 10:46 Go to previous message
andreas  is currently offline andreas
Messages: 239
Registered: January 2005
Location: Denmark

Site Admin
Well, if your domain is domain.com you could just use:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://www.domain.com%{REQUEST_URI} 
Previous Topic:redirect, but keep the same address in bar?
Next Topic:my seo friendly url is not working
Goto Forum:
  


Current Time: Sat May 17 07:42:10 CEST 2008

Powered by: FUDforum 2.7.7.
Copyright ©2001-2007 FUD Forum Bulletin Board Software