Forum Moderators: phranque

Message Too Old, No Replies

redirect www.site.com / site.com

         

wildnis

4:53 pm on Aug 1, 2005 (gmt 0)

10+ Year Member



I have another redirect problem:
some sites link to:
yoursite.com
instead of linking to
www.yoursite.com

when I use this redirect:
RewriteEngine On
rewritecond %{http_host} ^yoursite.com
rewriteRule ^(.*) [yoursite.com...] [R=301,L]

it also redirects my subdomain:
www.directory.yoursite.com

what is the right rewrite for this

thanks again - appreciate your help

[edited by: jdMorgan at 5:26 pm (utc) on Aug. 1, 2005]
[edit reason] No personal URLs, please. See TOS. [/edit]

jdMorgan

5:36 pm on Aug 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



wildnis,

Welcome to WebmasterWorld!

This makes no sense, unless the code you posted is not *exactly* what you put on your site. The code you posted only redirects domains that start with "yoursite<any_single_character>com".

Although probably unrelated to your current problem, I'd like to give you a friendly reminder that *every single character* in the code must be correct, or you may have problems. You may not freely mix case in the code without eventually having a problem.


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

After flushing your browser cache (Temporary internet files), try the version above with correct capitalization and escaping the literal period in the RewriteCond test of HTTP_HOST.

The only other possibilities I can think of is that your server is misconfigured, or that you are using some kind of "domain pointing redirection" service instead of a proper DNS setup.

Jim

wildnis

6:10 pm on Aug 1, 2005 (gmt 0)

10+ Year Member



Thank you Jim,

sorry for the homepage, now I know!

I donīt understand:

"and escaping the literal period in the RewriteCond test of HTTP_HOST."

Can you give me more info what you mean?
thanks again
Rolf

jdMorgan

7:20 pm on Aug 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In regular expressions -- as used on the right side of RewriteConds and the left side of RewriteRules -- "yoursite\.com" means "yoursite<period>com", while "yoursite.com" means "yoursite<any_single_character>com".

The "\" is used to "escape" the period, telling the regular-expressions parser to treat it as a literal period, rather than as a regular-expressions token meaning "any single character."

See the regular-expressions tutorial cited in our forum charter [webmasterworld.com] for more information.

Jim