Forum Moderators: phranque

Message Too Old, No Replies

non-www to www Rewrite with a twist

Issues with Primary and Addon domain redirecting

         

minarets

11:57 pm on Jul 19, 2007 (gmt 0)

10+ Year Member



I've got a Primary Domain set up in my hosting account, in the folder /public_html/

I've got an Addon Domain set up in a folder under that one, as /public_html/addondomainfolder/

(That Addon Domain also has subdomains, but I don't know if that matters)

What I would like to achieve is two-fold... In the Addon Domain, I would like to redirect all non-www requests to www...
At the same time, in the primary domain, I'd like to be able to redirect all requests to www.primarydomain.com/addondomainfolder/ AND www.primarydomain.com/addondomainfolder (no slash) back to www.primarydomain.com

I had originally set up my Addon Domain's .htaccess as so:

RewriteEngine on
RewriteCond %{HTTP_HOST}!^www\.addondomain\.com [NC]
RewriteCond %{HTTP_HOST}!^$
RewriteRule ^(.*) http://www.addondomain.com/$1 [R=301]

However, that causes requests to
www.primarydomain.com/addondomainfolder/
to be redirected to www.addondomain.com

and also requests to
www.primarydomain.com/addondomainfolder (no slash)
to be redirected to www.addondomain.com//home/#*$!XX/public_html/addondomainfolder
and throwing a 404 error.

Is it not possible to achieve both of these goals? Ideally I would like to be able to redirect non-www to www for the addon domain, but at the same time be able to redirect www.primary.com/addonfolder/ back to primary.com simply because it masks the existence of the addon domain.

Anyone have any ideas or is this just not doable? The Apache version is 1.3.37 if that helps.

-min.

[edited by: jdMorgan at 4:16 am (utc) on July 21, 2007]
[edit reason] De-linked "addondomain.com" [/edit]

g1smd

11:31 pm on Jul 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have had this "filepath injection" problem very recently, and posted some code only a few days ago in... [webmasterworld.com...]

minarets

3:06 am on Jul 21, 2007 (gmt 0)

10+ Year Member



Thanks,

I'll give both those code samples a try this weekend and post back.

-min.

g1smd

6:14 pm on Jul 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Only one of them will work, depending on exactly what you want to do.