Forum Moderators: phranque

Message Too Old, No Replies

.htaccess redirect from sub.domain1.com to sub.domain2.com

         

echoniner

9:11 am on Oct 22, 2010 (gmt 0)

10+ Year Member



I am really struggling with this problem, and have tried every thing I can think of in my limited .htaccess knowledge to make this work:

I want to redirect every call to any page from one subdomain.domain.com to another, with variable parameters.

For instance, I want

http://subdomain.olddomain.com/index.php?many_variables_here


to permanently redirect to (with the addressbar in the browser reflecting the new)

http://subdomain.NEWdomain.com/index.php?many_variables_here


I'm redirecting one subdomain only to the same subdomain name at another domain (permanently...want all expired links to still work). That is, www.olddomain.com still exists and is not to redirected, just subdomain.olddomain.com is to redirect.

For what it's worth: olddomain is an add-on domain of newdomain.

Thanks!

echoniner

10:09 am on Nov 18, 2010 (gmt 0)

10+ Year Member



I put the following into a htaccess at FILEPATH public_html/sub/ :

RewriteEngine on
#
RewriteCond %{HTTP_HOST} ^(www\.)?mydomain\.com [NC]
RewriteRule ^(.*)$ http://sub.mydomain.com/$1 [R=301,L]


It seems both worked for me only on condition that I change the last line to be ^(.*)$ instead of ^sub/(.*)$

any idea why? (but it works, just want to learn)

fyi: I'm not being selective: I want no links whatsoever to be to mydomain.com/sub/xyz

Jim... you are a true expert! thanks again for everything!

echoniner

5:53 am on Nov 24, 2010 (gmt 0)

10+ Year Member



thought I'd ping this...

Happy Thanksgiving all!

[edited by: jdMorgan at 10:09 pm (utc) on Nov 30, 2010]
[edit reason] Removed duplicate-post explosion [/edit]

jdMorgan

10:10 pm on Nov 30, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Because the path to the current directory is removed from the URL-paths 'seen' by RewriteRules in the .htaccess file in that directory. The URL-path examined by RewriteRule is 'localized' to the current directory in other words...

Jim

echoniner

9:20 am on Dec 4, 2010 (gmt 0)

10+ Year Member



Ah, I get it. Thank you again so very much! Happy holidays!
This 34 message thread spans 2 pages: 34