LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 03-12-2011, 09:26 AM   #1
PlymWS
Member
 
Registered: Aug 2006
Posts: 48

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


Hi,

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. http://domain.com/forums will now be at http://forums.domain.com.

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 :

Root
-Main
-Subdomains
--Forums
--Sub2

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
timetraveler
Member
 
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
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,909

Rep: Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326
Hi,

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

Regards
 
  


Reply


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


All times are GMT -5. The time now is 09:17 AM.

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