Forum Moderators: phranque

Message Too Old, No Replies

Rewrite help ... "-" in domain name

How do you do it?

         

shrirch

3:50 am on Apr 22, 2004 (gmt 0)

10+ Year Member



I've got this in my .htaccess

RewriteEngine on
RewriteCond %{HTTP_HOST}!^www\.kw1-kw2.com\.com
RewriteRule (.*) [kw1-kw2.com...] [R=permanent,L]

This causes a loop.

Any idea on what I'm doing wrong? Works on domains without '-'s in them.

jdMorgan

5:25 am on Apr 22, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



To be clear, you're saying that something like this loops?

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.apples-oranges\.com
RewriteRule (.*) http://www.apples-oranges.com/$1 [R=permanent,L]

I fixed what appeared to be a typo - an extra \.com in your code, and also fixed the missing space before "!" in the RewriteCond pattern.
The extra \.com itself would cause the problem, since your domain name can never end with ".com.com"

The only other thing I can think of is that inside square brackets, "-" defines a range of numbers or letters, such as [a-z] or [A-Z] or [0-9]. If mod_rewrite is getting confused, precede the "-" with a "\" to escape it. I have never had to do that unless the "-" was wthin square brackets, though.

Jim