Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

how to redirect browsers to the proper subfolder depending on what url was typed in

Posted on 2009-05-03
2
Medium Priority
?
285 Views
Last Modified: 2012-05-06
I have web hosting with 1and1 on a linux package. There are several domains in the package, and if I go to any of the domains I get the index.html that is in the root folder of my package. What I need to have happen is that someone browsing goes to the index.html that is in a subdirectory under the root directory. The different subdirectories pertain to the different domains. I've done this before on a Windows host with a default .asp file. I put a sample in the "code" section here. The sample will use domains  a.com, b.com, and c.com. I believe I will now how to do this with a perl script or a .htaccess file, or both, but I'm not sure
<%EnableSessionState=False
 
host = Request.ServerVariables("HTTP_HOST")
 
if host = "a.com" or host = "www.a.com" then
response.redirect("http://a.com/a/index.htm")
 
elseif host = "b.com" or host = "www.b.com" then
response.redirect("http://b.com/b/index.html")
 
elseif host = "c.com" or host = "www.c.com" then
response.redirect("http://c.com/c/index.htm")
 
else
response.redirect("http://a/a/index.htm")
 
end if
%>

Open in new window

0
Comment
Question by:bwierzbicki
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 2000 total points
ID: 24293609
0
 

Author Comment

by:bwierzbicki
ID: 24294968
Ok, I tried the code below. I put .htaccess in the root folder, I have subfolders a, b, c and when I entered the website I got:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webadmin@kundenserver.de and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.


Options +ExecCGI
RewriteEngine On
RewriteBase /

# if the internal redirect in the 2nd rewriterule works this
# rule stops the rewriteengine from looping continually
RewriteCond %{ENV:REDIRECT_STATUS} ^200.*
RewriteRule ^ - [L]

# the http_host is http://www.example.com or example.com or
# example2.com etc. This grabs whatever is before the .com
# and after the www. so it will be example or example2 or example3
# and puts that in the variable %2. so this redirects internally requests
a.com-> from / -> /a/
b.com-> from / -> /b/
c.com-> from / -> /c/
# example4.com-> from / -> /example4/
#
# so a request for example3.com/test/index.html is served from
# /var/vhosts2/henrik/public_html/example3/test/index.html
RewriteCond %{HTTP_HOST} ^([a-z]+\.)?(.+)\.[a-z]+$ [NC]
RewriteRule ^(.*)$ %2/$1[L]
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial will discuss fancy secure registration forms, with AJAX technology support. In this article I assume you already know HTML and some JS. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you mig…
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question