Forum Moderators: phranque

Message Too Old, No Replies

Help rewrite a directory to a subdomain

         

wplum

9:50 pm on Jul 9, 2006 (gmt 0)

10+ Year Member



Hi,

I want to rewrite a directory to an other subdomain but don't know how to do it.

Like this,
Redirect [mydomain1.com...] to [forums.mydomain2.com...]

Also,
Redirect [mydomain1.com...] to [mydomain2.com...]

Please help.

Thanks!

John Carpenter

10:52 am on Jul 10, 2006 (gmt 0)

10+ Year Member



Insert something like this into your Apache config (between <Directory "/"> and </Directory>), if you have mod_rewrite installed and enabled:

RewriteCond %{REQUEST_URI} ^/forum/
RewriteRule /forum/(.*) [forums.mydomain2.com...] [R=permanent,L]

RewriteCond %{REQUEST_URI}!^/forum/
RewriteRule /(.*) [mydomain2.com...] [R=permanent,L]

wplum

12:15 pm on Jul 10, 2006 (gmt 0)

10+ Year Member



Thank you very much, John.

I've tried, it works fine.
Here is the code I insert into my httpd.conf.

<VirtualHost *:80>
ServerAlias mydomain1.com
ServerAdmin admin@mydomains.com
DocumentRoot /var/www/html/mydomain1
ServerName www.mydomian1.com

<Directory /var/www/html/mydomain1>
Options FollowSymLinks ExecCGI Includes Indexes
AllowOverride all
Order allow,deny
Allow from all
</Directory>

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/forums/
RewriteRule /forums/(.*) [forums.mydomain2.com...] [R=permanent,L]

</VirtualHost>

John Carpenter

6:00 pm on Jul 10, 2006 (gmt 0)

10+ Year Member



Thank you very much, John.

I'm glad I could help.