Forum Moderators: phranque

Message Too Old, No Replies

Subdomain problems

         

AttackCow

8:55 pm on Oct 5, 2007 (gmt 0)

10+ Year Member



Hi, I've been searching and playing with different combinations of commands for days and I'm lost.

What I want to do is very common and probably very easy to do:
I want http://www.example.com/forum to be http://forum.example.com

I have a htaccess in my main directory that is set up like this:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^subdomain.example.com$
RewriteCond %{REQUEST_URI} !^/subdomain/
RewriteRule ^(.*) http://%{HTTP_HOST}/subdomain/$1
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.subdomain.example.com$
RewriteCond %{REQUEST_URI} !^/subdomain/
RewriteRule ^(.*) http://%{HTTP_HOST}/subdomain/$1

When I go to http://forum.example.com it redirects to http://forum.example.com/forum. How can I make it simple http://forum.example.com?

Thanks!

[edited by: jdMorgan at 4:37 am (utc) on Oct. 6, 2007]
[edit reason] example.com [/edit]

jbroder

9:16 pm on Oct 5, 2007 (gmt 0)

10+ Year Member



I am not sure that this is possible with .htaccess

I think this is more of an apache http.conf config thing.

In http.conf you would create an extra virtualhost record for forum.domain.com that points to the folder that the forum is in.

jdMorgan

4:34 am on Oct 6, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This single rule replaces both of yours, and does an internal rewrite to the /subdomain subdirectory for either "www" or "non-www" subdomain.example.com

RewriteEngine On
#
RewriteCond %{HTTP_HOST} ^(www\.)?subdomain\.example\.com
RewriteCond %{REQUEST_URI} !^/subdomain/
RewriteRule (.*) /subdomain/$1 [L]

Jim

AttackCow

8:42 pm on Oct 6, 2007 (gmt 0)

10+ Year Member




Thanks for the responses :)

Well I replaced my htaccess code with what jdMorgan wrote and now it pulls a 404 error.

Here's how my files on the server are set up:

public_html>>subdomain

I also tried putting a "subdomain" folder in the main directory, no dice. Any idea what I'm doing wrong?

Like I said earlier, my previous htaccess code would work but bring up "subdomain.domain.com/subdomain" instead of just "subdomain.domain.com".

Thanks!

jdMorgan

9:22 pm on Oct 6, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Look at your server error log -- It will often tell you exactly what is wrong. In this case, it is possible that you may need to use the RewriteBase directive, and the error log may show you the path info you need.

Jim