...

View Full Version : Forwarding non-www to www on http AND https



Riboflavin
02-08-2008, 07:10 AM
Hi all, I am trying to forward an traffic that comes to http://mysite.com to http://www.mysite.com but I also need to forward https://mysite.com to https://www.mysite.com

I've been trying to figure out how to do this with htaccess, but I can't find anything to forward both appropriately.

Thanks for any help :thumbsup:

oesxyl
02-08-2008, 07:14 AM
Hi all, I am trying to forward an traffic that comes to http://mysite.com to http://www.mysite.com but I also need to forward https://mysite.com to https://www.mysite.com

I've been trying to figure out how to do this with htaccess, but I can't find anything to forward both appropriately.

Thanks for any help :thumbsup:

how do you decide what from http://mysite.com go to http://www.mysite.com and what to https://www.mysite.com?

best regards

Riboflavin
02-08-2008, 07:19 AM
how do you decide what from http://mysite.com go to http://www.mysite.com and what to https://www.mysite.com?

best regards
Here is my existing .htaccess (using magento ecommerce)


############################################
## uncomment these lines for CGI mode
## make sure to specify the correct cgi php binary file name
## it might be /cgi-bin/php5-cgi

#Action php5-cgi /cgi-bin/php-cgi
#AddHandler php5-cgi .php

############################################
## this line is specific for 1and1 hosting

#AddType x-mapp-php5 .php

############################################
## default index file

DirectoryIndex splash.html index.php index.html index.htm

<IfModule mod_php5.c>

############################################
## adjust memory limit

php_value memory_limit 32M

############################################
## disable magic quotes for php request vars

php_flag magic_quotes_gpc off

############################################
## enable php short tags for templates

php_flag short_open_tag on

</IfModule>

<IfModule mod_ssl.c>

############################################
## make HTTPS env vars available for CGI mode

SSLOptions StdEnvVars

</IfModule>

<IfModule mod_rewrite.c>

############################################
## enable rewrites

Options +FollowSymLinks
RewriteEngine on

############################################
## you can put here your magento root folder path relative to web root

#RewriteBase /magento/

############################################
## always send 404 on missing files in these folders

RewriteCond %{REQUEST_URI} !^/(media|skin|js)/

############################################
## never rewrite for existing files, directories and links

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l

############################################
## rewrite everything else to index.php

RewriteRule .* index.php

</IfModule>


############################################
## Prevent character encoding issues from server overrides
## If you still have problems, use the second line instead

AddDefaultCharset Off
#AddDefaultCharset UTF-8
Order allow,deny
Allow from all

oesxyl
02-08-2008, 07:26 AM
I don't express my self to clear, :)
how do you want to be? what url go where? you probably have an idea how , isn't it?

best regards

Riboflavin
02-08-2008, 07:30 AM
Oh I see. Well I want it to redirect all URLs, I just want all pages to have www for seo purposes.

oesxyl
02-08-2008, 07:35 AM
Oh I see. Well I want it to redirect all URLs, I just want all pages to have www for seo purposes.
ok, that means all url to http//:www....?

best regards

Riboflavin
02-08-2008, 07:37 AM
ok, that means all url to http//:www....?

best regards

Correct, but also all https://url to https://www.url

CFMaBiSmAd
02-08-2008, 07:39 AM
This is off topic, but when posting a reply, it is not necessary to quote what was just posted in the previous post. That just makes for a longer read and makes it harder find what you wrote in your reply. Besides, we know that you are posting a reply related to the thread or you would not be posting (you don't get post points for how physically long you can make the thread.)

Only include a quoted portion of a post when you specifically want to call attention to something about that specific part of a post.

Riboflavin
02-08-2008, 07:45 AM
Sorry, I'm just used to posting on bigger boards that move a lot faster, and if you don't quote posts get out of order rather quickly.

Is it really that hard to determine what is a quote and what is my post?

oesxyl
02-08-2008, 07:49 AM
try this in .htaccess:


Redirect permanent http://mydomain.com/ http://www.mydomain.com


and same for https.

best regards

abduraooft
02-08-2008, 08:03 AM
I found some useful urls
http://www.workingwith.me.uk/articles/scripting/mod_rewrite
http://www.workingwith.me.uk/blog/software/open_source/apache/mod_rewriting_an_entire_site

Riboflavin
02-08-2008, 10:24 PM
try this in .htaccess:


Redirect permanent http://mydomain.com/ http://www.mydomain.com


and same for https.

best regards

I tried this, but it doesn't seem to be redirecting at all :confused:


I found some useful urls
http://www.workingwith.me.uk/articles/scripting/mod_rewrite
http://www.workingwith.me.uk/blog/software/open_source/apache/mod_rewriting_an_entire_site

Thanks, I've read through these before. I found that this code works for http


RewriteEngine On
RewriteCond &#37;{HTTP_HOST} ^example\.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

However when I tried adding this code for https, It doesn't work:


RewriteEngine On
RewriteCond %{HTTPS_HOST} ^example\.com
RewriteRule (.*) https://www.example.com/$1 [R=301,L]

VIPStephan
02-08-2008, 11:06 PM
Hi all, I am trying to forward an traffic that comes to http://mysite.com to http://www.mysite.com but I also need to forward https://mysite.com to https://www.mysite.com

What you’re trying to do is one of the most useless things. Not only is this completely useless, also www. is deprecated (http://no-www.org/) so just forget it and rather redirect www. domains to their correct and actual non-www equivalent, will ya? :rolleyes:

Riboflavin
02-09-2008, 01:23 AM
What you’re trying to do is one of the most useless things. Not only is this completely useless, also www. is deprecated (http://no-www.org/) so just forget it and rather redirect www. domains to their correct and actual non-www equivalent, will ya? :rolleyes:
And who exactly is proclaiming it as depreciated? Some group of elitist web developers at no-www? Stop spamming my thread with useless links, will ya? :rolleyes:

oesxyl
02-09-2008, 01:34 AM
I tried this, but it doesn't seem to be redirecting at all :confused:

it must work if is not a typo somewhere, I use this few times.
you could check by requesting one of your site page without www from your browser. If work few seconds after request the page address in browser must change.



Thanks, I've read through these before. I found that this code works for http


RewriteEngine On
RewriteCond &#37;{HTTP_HOST} ^example\.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

However when I tried adding this code for https, It doesn't work:
[QUOTE]
try to find in what directory you must the documents for https, :)
I guess is not the same with http, :)

PS: IMO pr is not so important for seo, was just a way to evaluate your position



[quote]
And who exactly is proclaiming it as depreciated? Some group of elitist web developers at no-www? Stop spamming my thread with useless links, will ya?

are few things here:
- elite means progress
- no-www make some sens, you could call me user-oesxyl and I call you user-riboflavin but user-vipstephan could say that is somehow redundant if we use coding forums ( http protocol, :) )
- you have an option in google webtools with prefered domain so you can avoid redirection, is a better option

PS: I have no opininion about no-www



best regards

vossjames
07-26-2010, 06:58 PM
.htaccess >>

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

============================================

Works perfect for me! Moves non-WWW-DOMAIN-EXTENSION to WWW-DOMAIN-EXTENSION.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum