Active TopicsActive Topics  Display List of Forum MembersMemberlist  HelpHelp   RegisterRegister  LoginLogin
ISAPI_Rewrite 2.x
 Helicon Tech : ISAPI_Rewrite 2.x
Subject Topic: Google Redirecting non-www version to www Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
morich
Newbie
Newbie


Joined: 25 April 2010
Location: United Kingdom
Online Status: Offline
Posts: 15
Posted: 23 May 2010 at 3:41am | IP Logged Quote morich

Hi need to do Redirecting www version to non-www foe a dot mobi site can you help i found the code below on your site for Redirecting non-www version to www

also i wont to stop any ? quary strings

iam looking for a google frendley way of doing this many thanks

If your web site is accessible through both versions of URL, i.e. http://helicontech.com and http://www.helicontech.com it is a good idea to redirect one version to another to avoid possible duplicate content penalty from search engines. Here is a rule to generally 301 redirect everything non-www to the corresponding www resource.
RewriteEngine on

RewriteCond %{HTTPS} (on)?
RewriteCond %{HTTP:Host} ^(?!www\.)(.+)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http(?%1s)://www.%2%3 [R=301,L]
Back to Top View morich's Profile Search for other posts by morich
 
morich
Newbie
Newbie


Joined: 25 April 2010
Location: United Kingdom
Online Status: Offline
Posts: 15
Posted: 25 May 2010 at 12:39am | IP Logged Quote morich

can any one help me on this
Back to Top View morich's Profile Search for other posts by morich
 
Anton
Admin Group
Admin Group


Joined: 30 January 2007
Location: Ukraine
Online Status: Offline
Posts: 10489
Posted: 25 May 2010 at 4:28am | IP Logged Quote Anton

Please try to apply the following config:

RewriteCond %{HTTPS} (on)?
RewriteCond %{HTTP:Host} ^(?!www\.)(.+\.mobi)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http(?%1s)://www.%2%3? [R=301,L]

__________________
Regards,
Anton
Back to Top View Anton's Profile Search for other posts by Anton
 
morich
Newbie
Newbie


Joined: 25 April 2010
Location: United Kingdom
Online Status: Offline
Posts: 15
Posted: 25 May 2010 at 7:24am | IP Logged Quote morich

Hi tryed that does not work???

[ISAPI_Rewrite]
RewriteCond %{HTTPS} (on)?
RewriteCond %{HTTP:Host} ^(?!www\.)(.+\.mobi)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http(?%1s)://www.%2%3? [R=301,L]

should i have put RewriteEngine on not [ISAPI_Rewrite] ????
also it is in a file called httpd is this right ??? sorry for being a pain


Back to Top View morich's Profile Search for other posts by morich
 
Anton
Admin Group
Admin Group


Joined: 30 January 2007
Location: Ukraine
Online Status: Offline
Posts: 10489
Posted: 25 May 2010 at 8:14am | IP Logged Quote Anton

If you are using ISAPI_Rewrite v2, then your config file should be called httpd.ini and the config should be:

[ISAPI_Rewrite]
RewriteCond %HTTPS (on)?
RewriteCond Host: ^(?!www\.)(.+\.mobi)$
RewriteRule (.*) http(?1s)\://www.$2$3 [RP]

__________________
Regards,
Anton
Back to Top View Anton's Profile Search for other posts by Anton
 
morich
Newbie
Newbie


Joined: 25 April 2010
Location: United Kingdom
Online Status: Offline
Posts: 15
Posted: 25 May 2010 at 5:28pm | IP Logged Quote morich

ok i try it out thanks
by the way what is the one for

Redirecting www version to non-www
Back to Top View morich's Profile Search for other posts by morich
 
morich
Newbie
Newbie


Joined: 25 April 2010
Location: United Kingdom
Online Status: Offline
Posts: 15
Posted: 25 May 2010 at 5:44pm | IP Logged Quote morich

[ISAPI_Rewrite]
RewriteCond %HTTPS (on)?
RewriteCond Host: ^(?!www\.)(.+\.mobi)$
RewriteRule (.*) http(?1s)\://www.$2$3 [RP]

HI this does not work gets www.mysite.mobi only
i wont mysite.mobi only
Back to Top View morich's Profile Search for other posts by morich
 
Anton
Admin Group
Admin Group


Joined: 30 January 2007
Location: Ukraine
Online Status: Offline
Posts: 10489
Posted: 26 May 2010 at 4:37am | IP Logged Quote Anton

Redirecting www version to non-www:

[ISAPI_Rewrite]
RewriteCond %HTTPS .*(on)?.*
RewriteCond Host: www\.(.+\.mobi)
RewriteRule (.*) http(?1s)\://$2$3 [RP]

And as for existing non-www to www rule, please try the following:

[ISAPI_Rewrite]
RewriteCond %HTTPS .*(on)?.*
RewriteCond Host: ^(?!www\.)(.+\.mobi)$
RewriteRule (.*) http(?1s)\://www.$2$3 [RP]

__________________
Regards,
Anton
Back to Top View Anton's Profile Search for other posts by Anton
 
morich
Newbie
Newbie


Joined: 25 April 2010
Location: United Kingdom
Online Status: Offline
Posts: 15
Posted: 28 May 2010 at 1:01am | IP Logged Quote morich

Hi thanks
the Redirecting www version to non-www: works ok
but i did notice that i need to stop the quary string
ie: http://mysite.mobi/newpage.htm?ArdSI=2a2f390a16e0
only want this http://mysite.mobi/newpage.htm

[ISAPI_Rewrite]
RewriteCond %HTTPS .*(on)?.*
RewriteCond Host: www\.(.+\.mobi)
RewriteRule (.*) http(?1s)\://$2$3 [RP]

and this one can you just look at again for me as i need to stop ? quary string and also this is a .co.uk site

And as for existing non-www to www rule, please try the following:

[ISAPI_Rewrite]
RewriteCond %HTTPS .*(on)?.*
RewriteCond Host: ^(?!www\.)(.+\.co\.uk)$
RewriteRule (.*) http(?1s)\://www.$2$3 [RP]

many thanks for your great help on this gary

Back to Top View morich's Profile Search for other posts by morich
 
Anton
Admin Group
Admin Group


Joined: 30 January 2007
Location: Ukraine
Online Status: Offline
Posts: 10489
Posted: 28 May 2010 at 4:04am | IP Logged Quote Anton

To stop query string, please try to use this:

[ISAPI_Rewrite]
RewriteCond %HTTPS .*(on)?.*
RewriteCond Host: ^(?!www\.)(.+\.co\.uk)$
RewriteRule (.*?)(?:\?.+)? http(?1s)\://www.$2$3 [RP]

__________________
Regards,
Anton
Back to Top View Anton's Profile Search for other posts by Anton
 
morich
Newbie
Newbie


Joined: 25 April 2010
Location: United Kingdom
Online Status: Offline
Posts: 15
Posted: 28 May 2010 at 6:59am | IP Logged Quote morich

Hi works ok when you use this
http://mysite.co.uk/one/two.htm?ArdSI=2a2f396967c7706d5d172ac64e0a16e0
stops stop query string ok thanks

BUT WHEN SOMEONE USES http://www.mysite.co.uk/one/two.htm?ArdSI=2a2f396967c7706d5d172ac64e0a16e0

it does not work sorry
Back to Top View morich's Profile Search for other posts by morich
 
Anton
Admin Group
Admin Group


Joined: 30 January 2007
Location: Ukraine
Online Status: Offline
Posts: 10489
Posted: 28 May 2010 at 7:14am | IP Logged Quote Anton

Ooops, sorry, I've made a mistake. It should be like this:

[ISAPI_Rewrite]
RewriteCond %HTTPS .*(on)?.*
RewriteCond Host: ^(.+\.co\.uk)$
RewriteRule (.*?)(?:\?.+)? http(?1s)\://$2$3 [R]

RewriteCond %HTTPS .*(on)?.*
RewriteCond Host: ^(?!www\.)(.+\.co\.uk)$
RewriteRule (.*) http(?1s)\://www.$2$3 [RP]



__________________
Regards,
Anton
Back to Top View Anton's Profile Search for other posts by Anton
 
morich
Newbie
Newbie


Joined: 25 April 2010
Location: United Kingdom
Online Status: Offline
Posts: 15
Posted: 31 May 2010 at 4:18am | IP Logged Quote morich

hi
do i use all this or can you just stop query string if someone comes in on the www side also i dont want asap

[ISAPI_Rewrite]
RewriteCond %HTTPS .*(on)?.*
RewriteCond Host: ^(.+\.co\.uk)$
RewriteRule (.*?)(?:\?.+)? http(?1s)\://$2$3 [R]

RewriteCond %HTTPS .*(on)?.*
RewriteCond Host: ^(?!www\.)(.+\.co\.uk)$
RewriteRule (.*) http(?1s)\://www.$2$3 [RP]


Back to Top View morich's Profile Search for other posts by morich
 
Anton
Admin Group
Admin Group


Joined: 30 January 2007
Location: Ukraine
Online Status: Offline
Posts: 10489
Posted: 31 May 2010 at 8:08am | IP Logged Quote Anton

Let me explain:

this part
RewriteCond %HTTPS .*(on)?.*
RewriteCond Host: ^(.+\.co\.uk)$
RewriteRule (.*?)(?:\?.+)? http(?1s)\://$2$3 [R]
redirects requested URL with query string to the same URL but WITHOUT query string.

this part
RewriteCond %HTTPS .*(on)?.*
RewriteCond Host: ^(?!www\.)(.+\.co\.uk)$
RewriteRule (.*) http(?1s)\://www.$2$3 [RP]
redirects non-www requests to www

Is that what you want?

__________________
Regards,
Anton
Back to Top View Anton's Profile Search for other posts by Anton
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum