Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Server
User Name
Linux - Server This forum is for the discussion of Linux Software used in a server related context.


  Search this Thread
Old 03-12-2011, 09:26 AM   #1
Registered: Aug 2006
Posts: 51

Rep: Reputation: 16
.htaccess redirect non-existent directory to subdomain


Im reorganising my web diretory because it's become messy. I've changed the structure of things so that folders below root are now subdomains e.g. will now be at

What I want to do is put a .htaccess redirect in place so that requests for the forums diretcory get routed to the subdomain. However the answers I've found on Google aren't working.

The new directory structure is like this :


The domain is setup so that the directory "Main" is its root and that works fine. The problem is that trying to goto /forums 404s because the directory doesn't exist.

Ideally I would like to have any request for a directory below root to be redirected to the subdomain directory automatically so I can add subdomain directories and they will automatically work if the directory exists.
Old 03-12-2011, 10:56 AM   #2
Registered: Apr 2010
Posts: 243
Blog Entries: 2

Rep: Reputation: 31
Since you have control of the server you should not use .htaccess.
Have a look at the rewrite module. It will let you do what you want.
Try some things and let us know if isn't working.
Old 03-12-2011, 11:19 AM   #3
LQ Guru
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,845

Rep: Reputation: 1596Reputation: 1596Reputation: 1596Reputation: 1596Reputation: 1596Reputation: 1596Reputation: 1596Reputation: 1596Reputation: 1596Reputation: 1596Reputation: 1596

If you have a couple of URLs that you want to redirect to subdomains according the requested URI, you can use:
Redirect /forums
Of more redirects, you can use wildcards with mod_rewrite as mentioned by the previous poster



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache httpd.conf Redirect Subdomain firefly2442 Linux - Server 4 05-10-2012 03:05 AM
how to redirect a subdomain to another server? machinakias Linux - Server 1 12-06-2010 03:41 PM
apache redirect to a different subdomain uglyoldbob Linux - Server 0 08-18-2009 05:57 PM
LXer: Subdomain Redirection Using htaccess And mod_rewrite On Apache For Linux Or Uni LXer Syndicated Linux News 0 02-27-2009 09:00 AM
mod_rewrite: redirect depending on subdomain mysql_connect Linux - Server 1 08-01-2007 06:23 AM > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 12:58 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration