Forum Moderators: phranque

Message Too Old, No Replies

hostname canonicalization problem

cant make it work for .info

         

omoutop

9:55 am on Jun 24, 2010 (gmt 0)

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



This seemed quit easy.. redirect/.rewrite example.info to www.example.info
Yet the following code failes.

RewriteCond %{HTTP_HOST} ^example.info
RewriteRule (.*) http://www.example.info/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^/]+/)*index\.html([#?][^\ ]*)?\ HTTP/
RewriteRule ^(([^/]+/)*)index\.html$ http://www.example.info/$1 [R=301,L]

This works perfectly on example.com.
example.com -> www.example.com
and www.example.com/index.html ->www.example.com

Why this does not work on .info domain?

jdMorgan

4:03 pm on Jun 24, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Dunno... How does it "not work?"

How are example.com and example.info related? -- Same server? Same filespace?

Without knowing details, the only possible answer is "Because something is broken."

Jim

g1smd

7:14 pm on Jun 24, 2010 (gmt 0)

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



One thing that is certainly wrong is that the index condition and rule should be listed before the general redirect condition and rule.

That is lines 3 and 4 should actually be first.

omoutop

5:58 am on Jun 25, 2010 (gmt 0)

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



@jdMorgan
when i say it doesnt work i mean it does not redirect example.info to www.example.info
the 2 domains are irrelevant to each other (they are on same server, but belong to different clients)

@g1smd
thank you for the info

jdMorgan

4:35 pm on Jun 25, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Where is this code located in respect to the 'filespaces' of the example.com and the example.info domains?

Is 'example.info' an 'add-on domain' added using a control panel?

Are there any rules that *do* work in the example.info .htaccess file?

Jim

omoutop

6:32 am on Jun 28, 2010 (gmt 0)

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



this is all the rules in htaccess file

Options +FollowSymLinks
RewriteEngine on
RewriteOptions inherit
RewriteBase /
#######################################################
##### rewrite example.info into www.example.info #####
######################################################

#RewriteCond %{HTTP_HOST} ^example.info
#RewriteRule (.*) http://www.example.info/$1 [R=301,L]
#RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^/]+/)*index\.html([#?][^\ ]*)?\ HTTP/
#RewriteRule ^(([^/]+/)*)index\.html$ http://www.example.info/$1 [R=301,L]

RewriteCond %{HTTP_HOST} !^www\.example\.info$
RewriteRule (.*) http://www.example.info/$1


#######################################################
##### prevent viweing of htaccess/robots.txt file #####
######################################################
<Files .htaccess>
order allow,deny
deny from all
</Files>
<Files robots.txt>
order allow,deny
deny from all
</Files>

#######################################################
##### custom error pages #####
######################################################
###ErrorDocument 404 /error_page.php


#################################################
##### Rerwite Rules #####
##################################################
RewriteRule ^job.html$ job.php [NC,L]
RewriteRule ^contact.html$ contact.php [NC,L]

g1smd

12:53 pm on Jun 28, 2010 (gmt 0)

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



# rewrite example.info into www.example.info

No. It does not do that at all.

It redirects external requests for any URL where the requested hostname is not exactly www.example.info to the new URL at www.example.info preserving the requested path, file and query string data in the redirect.

Understanding the difference between an external redirect and an internal rewrite is crucial here.


Beware that using the [NC] flag on your rewrites promotes Duplicate Content. With the [NC] flag, many different URLs can display exactly the same content. That's not a good idea.

omoutop

1:38 pm on Jun 28, 2010 (gmt 0)

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



you are corect, but still this rule does not redict non www requests to www requests.

any idea?
the same code works on .com, .gr domans, but failes in .info domains.
why?

jdMorgan

1:18 am on Jul 10, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There is no reason that it should not work on one domain but work another.

There are many reasons that it might not work in one virtual server but not in another. However, this would be due to differences in the server (VirtualHost) configuration, and not due to some problem in your code (which looks OK).

Jim