0

Would I be possible to rewrite forum.mydomain.org to mydomain.org/forum/ with mod_rewrite?

Because I cant get subdomains working

-- Update --

Sorry Chris, your answer didn't work.

My domain has an subdomain called forum with an a-record with my ip

My Hosts file:

127.0.0.1       localhost
127.0.0.1       forum

httpd-vhosts.conf

<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot "c:/wamp/www"
ServerName localhost
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
</VirtualHost>

<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot "c:/wamp/www/forum"
ServerName forum
ErrorLog "logs/your_own-error.log"
CustomLog "logs/your_own-access.log" common
</VirtualHost>
Mark Henderson
  • 68,823
  • 31
  • 180
  • 259

2 Answers2

1

firstly Yes its possible using a redirect, but more importantly why cant you get the subdomain to work? What issues are you encountering?

A little more detail and I can help you with the best solution.

DC

If you are getting "forbidden" you can rule out DNS issues. It would appear you have a configuration problem. most likely you haven't defined a default page and fancy indexing is disabled.

Try adding the folloing to httpd.conf

<IfModule mod_autoindex.c>
  IndexOptions FancyIndexing
</ifModule>

and make sure mod_autoindex is loaded

Take a look at your virtual server config for the subdomain. compare it to the one for your main domain.

Remember that virtual servers override the main configuration, In other words if something is defined in the main config part (anything outside ) it remains in force for your virtualhost. so either change it in the main section of httpd.conf or add it to your virtualhost.

Perhaps if you post it your config (just the relevant parts such as the virtual servers) we can suggest alterations

DC

Your Virtualserver config looks fine.

Without seeing a lot more of your configuration I would hazard a guess to say the problem is with the forum software. if you can enter the forum via localhost/forum/index.php but not forum/index.php Then I would say that the forum software is configured to use an incorrect domain name. Probably it was setup to use localhost rather than forum as the domain name. and probably it has also been configured to use the directory /forum/ rather than the root folder

This is just guesswork as its hard to determine the exact cause without a closer look.

If you create a file called /forum/test.html can you access it using http://forum/test.html ?

You may need to rename any .htaccess files to disabled.htaccess so they don't interfere. rename all .htaccess files in the path eg: even one in C:\wamp\www if one exists

DC

  • well i followed this guide: http://viralpatel.net/blogs/2009/09/how-to-setup-multiple-virtual-hosts-in-wamp.html and now i get 403 forbidden if i try to access my site with my domain, its works only iwht localhost –  Jan 06 '10 at 01:51
1

Yes you can, but you don't need to. Just use a redirect:

<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName forum.mydomain.org
ErrorLog "logs/your_own-error.log"
CustomLog "logs/your_own-access.log" common
Redirect Permanent http://www.mydomain.org/forum/ 
</VirtualHost>

A couple of notes looking at the config you posted,

  1. You need to have NameVirtualHost set to *:80 for your config to work
  2. "forum.mydomain.org" won't currently work because you don't have a virtual host entry for it. You need to add a block like the one above.

What may be happening is when you try to hit forum.mydomain.org it doesn't match any VirtualHost (seeing as it's not defined). So apache uses the default VirtualHost, which I believe is the first VirtualHost you defined.

David
  • 3,555
  • 22
  • 17