Redirect everything to Subdomain except /

Using a single web hosting account to host multiple sites

Redirect everything to Subdomain except /

Postby Till Kraemer » Sun Aug 24, 2008 10:51 am

Hello...

I browsed through the docs and this board but somehow got lost...

I want to redirect www.domain.com/almost_everything to
sub.domain.com/almost_everything except www.domain.com/ which
should redirect to www.domain.com/index.php

Is that somehow possible (I mean except through magic)?

Currently my .htaccess in www.domain.com/ looks something like:

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


But that of course redirects www.domain.com/ to sub.domain.com/ -
which it shoulnd't... :|

Any Ideas? Thank you so much...

Cheers,

Till
Till Kraemer
 
Posts: 2
Joined: Sun Aug 24, 2008 10:41 am

Postby richardk » Sun Aug 24, 2008 2:16 pm

.* matches nothing (just example.com/).

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

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


Or
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule !^(index\.php)?$ http://sub.example.com%{REQUEST_URI} [R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Thanks a lot!

Postby Till Kraemer » Sun Aug 24, 2008 2:24 pm

Terrific! Worked like a charm... Thank you very much!

Cheers,

Till
Till Kraemer
 
Posts: 2
Joined: Sun Aug 24, 2008 10:41 am


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 1 guest

cron