1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

.htaccess - redirect to subfolder AND make "www" work

Discussion in 'Web Design & Development' started by demonico, Jul 11, 2012.

Thread Status:
Not open for further replies.
Advertisement
  1. demonico

    demonico Thread Starter

    Joined:
    Jul 11, 2012
    Messages:
    2
    I'm working with a client and an element of my htaccess file is simultaneously working and not working.

    Here's the htaccess file as it stands now:

    Code:
    Options +FollowSymLinks
     
    RewriteEngine On
    RewriteBase /
    
    RewriteCond %{HTTP_HOST} example1.com
    RewriteCond %{HTTP_HOST} www.example1.com
    RewriteCond %{REQUEST_URI} !EXAMPLE1/
    RewriteRule ^(.*)$ EXAMPLE1/$1 [L]
    
    RewriteCond %{HTTP_HOST} example2.org
    RewriteCond %{HTTP_HOST} www.example2.org
    RewriteCond %{REQUEST_URI} !EXAMPLE2/
    RewriteRule ^(.*)$ EXAMPLE2/$1 [L]
    This particular client has one hosting account with four websites hosted there in subfolders. I am trying to redirect traffic from example1.com to EXAMPLE1's subfolder (where it looks for index.html or whatever) while also allowing www vs. no-www to work in the domain bar.

    The strange part... example1 is working, example2 is not. They're setup basically identically and I don't see a problem in the code. Example1 loads perfectly, Example2 loads a blank page. Help?
     
  2. namenotfound

    namenotfound

    Joined:
    Apr 30, 2005
    Messages:
    3,012
    If you don't mind coding each redirect by hand, you could put this in a .htaccess file:

    HTML:
    Redirect 301 /site2 http://site2.domain.com/
    So if someone goes go www.domain.com/site2/ it will redirect to site2.domain.com/

    Is that kinda what you want?
     
  3. demonico

    demonico Thread Starter

    Joined:
    Jul 11, 2012
    Messages:
    2
    They are all separate domain names, all for separate companies. Be like for motherboard1, intel2, and videocard3.com - all as separate domain names, but under the same hosting account.
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1060598