Forum Moderators: bakedjake
I've searched the site for the answer, and I've tried many different ways to do this:
I'm on a virtual host (apache 2), root access, not setup as wildcard (using Aliases (CNAME) in my DNS servers)
[mysite.org...] to [subdir.mysite.org...]
( edited to add: both ways work, but I only want subdir.mysite.org )
My httpd.conf:
<VirtualHost [my ip goes here]>
DocumentRoot /var/www/html/forum
ServerName subdir.mysite.org
ServerAlias subdir.mysite.org www.subdir.mysite.org
</VirtualHost>
I've tried this:
Options +FollowSymLinks
RewriteEngine on
AcceptPathInfo on
RewriteCond %{HTTP_HOST} ^subdir\.mysite\org/(.*) [NC]
RewriteRule ^(.*)$ http://subdir.mysite.org/$1 [R=301]
which is as close as I can get to what I thought would work...I;'ve tried other variations from examples, but nojoy...
I did see many examples going from subdomain to subdir, but I need the opposite...
Thanks!
dpd
RewriteCond %{HTTP_HOST} ^subdir\.mysite\org/(.*) [NC]
RewriteRule ^(.*)$ http://subdir.mysite.org/$1 [R=301] You might want to change it to this, which says that if you are not ("!") on subdir.mysite.org, then you should be redirected to subdir.mysite.org:
RewriteCond %{HTTP_HOST} !^subdir\.mysite\.org [NC]
RewriteRule (.*) http://subdir.mysite.org/$1 [R=301,L] I think this should do it.
/claus
I tried your's and I got a 500 error. Anyway, I'm not too worried about the other way, as long as it works. It's only so that if someone tries to access the subdir, they get the subdomain instead. It's new, so search engines aren't an issue. I don't expect many access using this...
Thanks again,
dpd