Forum Moderators: phranque

Message Too Old, No Replies

rewrite rules help.again

         

mike2010

12:09 am on Jan 12, 2014 (gmt 0)

10+ Year Member



could I get some help on the proper 301 way (google friendly way) to forward

www.mydomain.com > secure.mydomain.com
mydomain > secure.mydomain.com

basically, yes the www and non-www version of the domain.

I figured GoDaddy could at-least provide enough support to help with this simple fix, but apparently not. They say they can't provide assistance with this.

I tried the following, but it only worked for the non-www version...not the www version -

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


I appreciate the assistance . Even if you recommend a method other than .htaccess or httpd.conf.

currently, i'm using a meta tag redirect=0' option just to have the site functional...but it's probably not the best method.

lucy24

1:42 am on Jan 12, 2014 (gmt 0)

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



mydomain > secure.mydomain.com

Assuming for the sake of discussion that you just forgot the dot com at the end?

Does everything go to secure.example.com? Or are there other subdomains that you need to preserve? If not, you only need to change the condition to say

RewriteCond %{HTTP_HOST} !^(secure\.example\.com)?$


If you do have other subdomains, are they wildcards or is there a small limited group?

:: wandering off to find out how long* you have to be a member before everyone waives the lecture on example dot com ::


* Although possibly the answer is "any date earlier than Apr 8, 2011" :(

mike2010

5:39 am on Jan 12, 2014 (gmt 0)

10+ Year Member




heyy...I remember you. One of the few that ever respond to me. :-/

yup, u were right...forgot the .com at the end.

and yes, only 1 subdomain needed.

I tinkered around with your idea...it worked for the non-www version....but www.version keeps going to itself. :-(

watcha think, maybe a separate condition for www ?

ur good with this stuff. :-)

g1smd

8:23 am on Jan 12, 2014 (gmt 0)

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



The code in the very first post says

If the requested hostname is NOT(!) exactly "www.example.com" then redirect to "secure.example.com".

This will produce an infinite loop.

You need to amend the pattern in the Condition, so that it tests for NOT "secure.example.com".

If there is a separate .htaccess wherever www requests resolve to on the server, perhaps comment out any RewriteRules that are in it?

mike2010

5:02 pm on Jan 12, 2014 (gmt 0)

10+ Year Member



well, the loop (if any) isn't in .htaccess...as it's the only coding I have in there currently.

www is still going to www. :(

I could live with this, as long as you think the following isn't too bad for seo -

my index.html page :


<html>
<head>
<title>my domain</title>
<META HTTP-EQUIV="refresh" CONTENT="0; url=

http://secure.mydomain.com">
<meta name="description" content="my domain">
<meta name="keywords" content="my domain">
</head>
<body>

</body>

</html>

lucy24

7:55 pm on Jan 12, 2014 (gmt 0)

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



In your original post, the Condition says "if not 'www dot etcetera'". In all replies, the suggested Condition says "if not 'secure dot etcetera'". Which form does your current htaccess have?

mike2010

6:41 pm on Jan 14, 2014 (gmt 0)

10+ Year Member



I currently have nothing in .htaccess, just using the meta redirect as specified above.

In initial post, I did try that version. But like I said, no matter what I do I can't seem to get both the WWW version and non-www version to both forward to the subdomain I specify. ( secure.mydomain.com )

If I could get the perfectly right .htaccess for this...that SHOULD work. Then I will troubleshoot where the loop my be that is keeping the WWW > WWW . All my current .htaccess efforts to get the WWW. version to go to secure.mydomain.com have failed. Which is why I had to use Meta Redirect.

lucy24

8:31 pm on Jan 14, 2014 (gmt 0)

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



If you don't have anything in htaccess, how can a rule either work or not work? What was the most recent version that didn't work?

I would expect to see

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


Use [ code ] tags to prevent auto-linking-- happens even with example.com once you use subdomains.

Do the forms example.com and www.example.com simply not exist?

g1smd

9:10 am on Jan 15, 2014 (gmt 0)

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



That's what I would expect.

If requested hostname is NOT secure.example.com, redirect to secure.example.com appending the originally requested path.

mike2010

3:45 pm on Jan 17, 2014 (gmt 0)

10+ Year Member




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


thx darlin, that fixed it.

what I posted in the initial post was the only code I tried.

figured it would still go to /secure/ if 'cond' was not www.

but ur right again. :)


---btw, what's going on with the load times here...takes 5 minutes after hitting 'submit' just to get our new replies to show up. very long load time-----

g1smd

7:07 am on Jan 18, 2014 (gmt 0)

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



However, "secure" is also "NOT www" so requests for "secure" are redirected to "secure" in an infinite loop.

Load times occasionally long here, not often and not for long. It is bad right now. If it persists it's probably at your end.