?
Solved

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

Posted on 2009-05-03
2
Medium Priority
?
282 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

Certified OpenStack Administrator Course

We just refreshed our COA course based on the Newton exam.  With 14 labs, this course goes over the different OpenStack services that are part of the certification: Dashboard, Identity Service, Image Service, Networking, Compute, Object Storage, Block Storage, and Orchestration.

Question has a verified solution.

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

Introduction This tutorial will give you a fast look what you can do with WhizBase. I expect you already know how to work with HTML at least, and that you understand the basics of the internet and how the internet works. WhizBase is a server-s…
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…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

800 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