Forum Moderators: phranque

Message Too Old, No Replies

Cyclic redirect when using mod rewrite

Problems about redirection

         

sebelk

1:52 pm on Jan 23, 2008 (gmt 0)

10+ Year Member



Let's say that I have domains called "something.com" and "something.com.ar". Also I have a non-ssl web server on IP (numbers are only examples) 200.42.213.2 (chicago) and and ssl web server on 200.42.213.4 (boston).

Well, I want that always the address on address bar in browser looks like "http://www.something.com.ar" and [wwws.something.edu...]

Rewriting on non-SSL server works fine but not on SSL server, browser reports "Cyclic redirect"

Non-ssl server www.something.com:

/etc/httpd/conf/httpd.conf

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www(.something.com.ar)?$ [NC,OR]
RewriteCond %{HTTP_HOST} ^(www.¦chicago.)?(something.com.ar¦other.com.ar¦other2.com)$ [NC,OR]
RewriteCond %{HTTP_HOST} ^chicago(.something.com¦.something.com.ar)?$ [NC,OR
]
RewriteCond %{HTTP_HOST} ^200.42.213.2$ [NC,OR]
RewriteCond %{HTTP_HOST} ^something.com(.ar)?$ [NC]
RewriteRule ^(.*)$ http://www.something.com/$1 [R=permanent,L]

SSL-Server /etc/httpd/conf.d/ssl.conf :

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(localhost¦boston¦200.42.213.4) [NC,OR]
RewriteCond %{HTTP_HOST} ^wwws.something.com.ar$ [NC,OR]
RewriteRule ^(.*)$ [wwws.something.edu...] [R=permanent,L]

What's wrong with this setting? Could you help me?

Thanks in advance!

[edited by: jdMorgan at 2:40 pm (utc) on Jan. 23, 2008]
[edit reason] de-linked [/edit]

jdMorgan

2:40 pm on Jan 23, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Remove the [OR] from the second RewriteCond in the https rule. There is no following RewriteCond for that RewriteCond to be [OR]ed with, so mod_rewrite [OR]s it with "True" by default. Therefore, the second rule is always executed, regardless of the domain.

Jim

sebelk

2:47 pm on Jan 23, 2008 (gmt 0)

10+ Year Member



Oh shame of me! deleted OR and worked!

One question more: should it be fine set [R] insted [R=permanent]

Thanks jdmorgan!

jdMorgan

4:40 pm on Jan 23, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



[R] is the same as [R=302] and generates a 302-Found response. This affects search engines, which follow the HTTP standards in handling 301 and 302 redirects differently. Make sure you understand the effects on the ranking of the redirected-from and redirected-to pages.

From what I see in this thread, I'd recommend a 301 redirect, not a 302.

Jim

sebelk

6:34 pm on Jan 23, 2008 (gmt 0)

10+ Year Member



Ooops, sorry Jim, I did the question in a wrong way, what I wanted to know is:

What is better for SEO

1) RewriteRule ^(.*)$ http://www.example.com/$1 [R=permanent,L]

or

2) RewriteRule ^(.*)$ http://www.example.com/$1 [L]

Suppose that www.example.com.ar and www.example.com has the same IP. (sorry for the stupid question) what is the difference between "rewriting" and "redirecting".

Sergio

[edited by: jdMorgan at 2:31 am (utc) on Jan. 24, 2008]
[edit reason] example.com [/edit]

jdMorgan

12:17 am on Jan 24, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Both of the above rules are redirects, because a full URL is specified as the substitution URL. The first rule generates a 301-Moved Permanently, while the second generates a 302-Found. A 301 tells search engines to change the URL in their database, while a 302 tells them not to change it. However, if you use a 302 (or an internal rewrite), then you essentially create duplicate content, and the two domains will "compete with each other" for ranking. You'll end up with one fairly-well-ranked, and the other gone, or with both poorly ranked, depending on the strength of the incoming links to each domain.

It's bad enough when some other Webmaster out-ranks your site. But even worse if you outrank yourself!

Your best bet is to use a 301, and promote only one of the domains, so as to avoid splitting their ranking.

Jim

jdMorgan

2:34 am on Jan 24, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Also, see this recent thread:

What's the difference between an external and an internal redirect? [webmasterworld.com]

Jim