Forum Moderators: phranque

Message Too Old, No Replies

Redirecting from IP to hostname not working

External redirect from old mod_userdir-format

         

grandma genie

7:11 pm on Jan 7, 2011 (gmt 0)

10+ Year Member



Hi Jim,

I am still finding visitors to my site coming from the old IP-based name and I would like to redirect them to the correct site name. This is what I have tried and it is not working. I don't know why. Can you see my error?

# Externally redirect old mod_userdir-format requests to canonical hostname
RewriteCond %{HTTP_HOST} ^24\.248\.nn\.nnn\ [NC]
RewriteCond %{SERVER_PORT}s ^(443(s)|[0-9]+s)$
RewriteRule ^(.*)$ http%2://www.mywebsite.com/$1 [R=301,L]

Thank you for your help.

Jeannie

g1smd

8:15 pm on Jan 7, 2011 (gmt 0)

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



HTTP_HOST does not need the trailing slash, nor the [NC] flag.

grandma genie

8:50 pm on Jan 7, 2011 (gmt 0)

10+ Year Member



It is now working, but only if the URL only contains the IP address. If there is anything after it, like this: 24.248.nn.nnn/other_directory/page.html it does not redirect. What am I forgetting?

g1smd

10:37 pm on Jan 7, 2011 (gmt 0)

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



...does not redirect

What does it do?


Make sure you use flush the browser cache before testing. Also test using the Live HTTP Headers extension for Firefox, and look very carefully at the reports.

grandma genie

1:36 am on Jan 8, 2011 (gmt 0)

10+ Year Member



Flushed the browser cache and it is working fine now. Thank you.

wilderness

3:01 am on Jan 8, 2011 (gmt 0)

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



Whats this trailing s:

RewriteCond %{SERVER_PORT}s

g1smd

9:03 am on Jan 9, 2011 (gmt 0)

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



It loads "s" into %2 when port is 443.

[edited by: jdMorgan at 5:04 pm (utc) on Jan 9, 2011]
[edit reason] Fixed typo only. [/edit]