Forum Moderators: phranque

Message Too Old, No Replies

Mod rewrite of www subdomain

         

greash

4:21 pm on Oct 27, 2005 (gmt 0)

10+ Year Member



Hi:

I want: http://www.example.com/dir directed to http://example.com/dir.

The dir is the part I'm really going after here in this instance.

I know it's something like this, but I don't want all the www sites to be redirected, only the one with the /dir.

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

How do I go about doing this?

Thanks.

[edited by: jdMorgan at 6:39 pm (utc) on Oct. 27, 2005]
[edit reason] Examplified. [/edit]

jdMorgan

6:38 pm on Oct 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In .htaccess:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^[b]dir/[/b](.*)$ http://example.com/[b]dir/[/b]$1 [R=301,L]

For more information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].

Jim

greash

7:10 pm on Oct 27, 2005 (gmt 0)

10+ Year Member



I tried what you suggested, but that didn't work. Any other ideas?