This forum has been moved here:
Helicon Tech Community Forum

Helicon Ape (Forum Locked Forum Locked)
 Helicon Tech : Helicon Ape
Subject Topic: mod_seo 301 rule - domain without www
Author
Message |
jamesnoon
Groupie


Joined: 07 December 2005
Location: United Kingdom
Posts: 79
Posted: 12 March 2011 at 8:55am

Hi

Can I have a rule that will auto redirect for example

mysite.com (and any other url)

To auto 301 redirect to enter the www, ie

mysite.com redirects to
www.mysite.com

mysite.com/mypage.htm redirects to
www.mysite.com/mypage.htm

etc etc

This way I don't have to create an extra site in IIS just for the 301 redirect.

Thanks, James
Back to Top Visit jamesnoon's Homepage
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 14 March 2011 at 3:22am

Sure, you can do this as follows:

RewriteBase /
RewriteCond %{HTTP_HOST} ^(?!www\..*)(.+)$ [NC]
RewriteRule (.*) http\://www.%1/$1 [R=301,L]

__________________
Regards,
Anton
Back to Top
 
jamesnoony
Newbie


Joined: 15 April 2009
Posts: 25
Posted: 14 March 2011 at 4:57pm

Hi, I tried that and it doesn't work. I have other rules as follows, any other
suggestion please?


# Helicon Ape version 3.0.0.61

#DirectoryIndex index.asp index.php

#SetEnvIfNoCase (%{REQUEST_URI} (.*) and %{QUERY_STRING} (.*))
REQUEST_URI=$1?$2

SetEnvIfNoCase Host ^www\.dltchiropody\.co\.uk$ mod_seo


#SetEnv mod_linkfreeze

#LinkFreezeRule /// "*"

RewriteEngine on
RewriteBase /

#RewriteCond %{HTTPS} (on)?
#RewriteCond %{HTTP:Host} ^(?!www\.)(.+)$ [NC]
#RewriteCond %{REQUEST_URI} (.+)
#RewriteRule .? http(?%1s)://www.%2%3 [R=301,L]
#
#RewriteLog temp-log.txt
#RewriteLogLevel 9
#
#

SeoRule ^/(.+\.asp)\?catID=(\d+)$ /$1/catID/$2 [NC,L]
RewriteRule ^(.+\.asp)/catID/(\d+)/?$ /$1?catID=$2 [NC,L]

SeoRule ^/(.+\.asp)\?catID=(\d+)&([^&=]+)=([^&=]+)$
/$1/catID/$2/$3/$4 [NC,L]
RewriteRule ^(.+\.asp)/catID/(\d+)/([^&=/]+)/([^&=/]+)/?$ /$1\?
catID=$2&$3=$4 [NC,L,O]

SeoRule ^/(.+\.asp)\?catID=(\d+)&(.*)$ /$1/catID/$2/$3 [NC,L]
RewriteRule ^(.+\.asp)/catID/(\d+)/(.*)$ /$1?catID=$2&$3 [NC,L]



SeoRule ^/(.+\.asp)\?SubcatID=(\d+)$ /$1/SubcatID/$2 [NC,L]
RewriteRule ^(.+\.asp)/SubcatID/(\d+)/?$ /$1?SubcatID=$2 [NC,L]

SeoRule ^/(.+\.asp)\?SubcatID=(\d+)&([^&=]+)=([^&=]+)$
/$1/SubcatID/$2/$3/$4 [NC,L]
RewriteRule ^(.+\.asp)/SubcatID/(\d+)/([^&=/]+)/([^&=/]+)/?$ /$1\?
SubcatID=$2&$3=$4 [NC,L,O]

SeoRule ^/(.+\.asp)\?SubcatID=(\d+)&(.*)$ /$1/SubcatID/$2/$3 [NC,L]
RewriteRule ^(.+\.asp)/SubcatID/(\d+)/(.*)$ /$1?SubcatID=$2&$3 [NC,L]

SeoRule /(.+\.asp)\?Content=(\d+)&(.*) /$1/Content/$2/$3 [NC,L]
RewriteRule ^(.+\.asp)/Content/(\d+)/(.*)$ /$1?Content=$2&$3 [NC,L]

SeoRule /(.+\.asp)\?NewsID=(\d+)&(.*) /$1/NewsID/$2/$3 [NC,L]
RewriteRule ^(.+\.asp)/NewsID/(\d+)/(.*)$ /$1?NewsID=$2&$3 [NC,L]

SeoRule /(.+\.asp)\?tid=(\d+) /$1/tid/$2 [NC,L]
RewriteRule ^(.+\.asp)/tid/(\d+) /$1?tid=$2 [NC,L]

SeoRule /(.+\.asp)\?ProductID=(\d+)&([^&=]+)=([^&=]+)&([^&=]+)
/$1/ProductID/$2/$3/$4/$5 [NC,L]
RewriteRule ^(.+\.asp)/ProductID/(\d+)/([^&=/]+)/([^&=/]+)/([^&=/]+)/?
$ /$1?ProductID=$2&$3=$4&$5 [NC,L]

SeoRule /(.+\.asp)\?ProductID=(\d+)&([^&=]+)=([^&=]+)
/$1/ProductID/$2/$3/$4 [NC,L]
RewriteRule ^(.+\.asp)/ProductID/(\d+)/([^&=/]+)/([^&=/]+)/?$ /$1?
ProductID=$2&$3=$4 [NC,L]

SeoRule /(.+\.asp)\?ProductID=(\d+)&([^&=]+) /$1/ProductID/$2/$3
[NC,L]
RewriteRule ^(.+\.asp)/ProductID/(\d+)/([^&=/]+)/?$ /$1?
ProductID=$2&$3 [NC,L]

SeoRule /(.+\.asp)\?ProductID=(\d+) /$1/ProductID/$2 [NC,L]
RewriteRule ^(.+\.asp)/ProductID/(\d+)/?$ /$1?ProductID=$2 [NC,L]

SeoRule /(.+\.asp)\?sid=(\d+)&(.*) /$1/sid/$2/$3 [NC,L]
RewriteRule ^(.+\.asp)/sid/(\d+)/(.*)$ /$1?sid=$2&$3 [NC,L]
Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 15 March 2011 at 4:21am

Your config is ok. The SeoRules are fine.
You need to uncomment this part to get www redirect working:

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

If it doesn't work, please enable logging in httpd.conf and provide rewrite.log records for some test request.

__________________
Regards,
Anton
Back to Top
 
jamesnoon
Groupie


Joined: 07 December 2005
Location: United Kingdom
Posts: 79
Posted: 18 March 2011 at 9:46am

Hi, thats not working

envie4u.co.uk      86400      IN A      83.138.156.180           
www.envie4u.co.uk      86400      IN CNAME      envie4u.co.uk

Please see my dns records for the site above, in IIS7 I have www.envie4u.co.uk set as the host header, bound to 83.138.156.180      

I would like that if I type envie4u.co.uk it will auto redirect to www.envie4u.co.uk.

Can this be done without creating another site in IIS specifically for the redirect.

Is there another setting I need to add in IIS?

Thanks, James
Back to Top Visit jamesnoon's Homepage
 
jamesnoon
Groupie


Joined: 07 December 2005
Location: United Kingdom
Posts: 79
Posted: 18 March 2011 at 10:45am

I have now got this to work , I needed to add the domain header in IIS without the www as an extra header, J
Back to Top Visit jamesnoon's Homepage
 

Sorry, you can NOT post a reply.
This forum has been locked by a forum administrator.

Printable version Printable version