Redirect just the root location of virtual host

I have a virtual host

 x.y.z.edu

and i have many sites that use it

x.y.z.edu/1/
x.y.z.edu/2/

but i need to redirect request for

x.y.z.edu/

to another site. How do i do this in the apache httpd.conf?
thanks!
chrismarxAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ghoti_AZCommented:
Looks like you want to use a 301 Redirect with IIS:

In internet services manager, right click on the file or folder you wish to redirect.
Select the radio titled "a redirection to a URL".
Enter the page that the page will be redirected to.
Check "The exact url entered above" and the "A permanent redirection for this resource".
Click on 'Apply'.

The subdirectories should still be accessible normally.
0
chrismarxAuthor Commented:
hmm, i posted this under apache, maybe its showing up in a different category, but I need to do this for apache server (by editing http.conf file)
0
caterham_wwwCommented:
with

  RedirectMatch 301 ^/$ http://othersite/

inside of your <virtualhost> for  x.y.z.edu
0
Protecting & Securing Your Critical Data

Considering 93 percent of companies file for bankruptcy within 12 months of a disaster that blocked access to their data for 10 days or more, planning for the worst is just smart business. Learn how Acronis Backup integrates security at every stage

Ghoti_AZCommented:
Apologies, somehow I got my apples and oranges in the wrong cart.  Indeed, you still want a 301 redirect.

Using htaccess to accomplish the 301 redirect is highly suggested due to it being fairly convenient to manage, rather than setting redirects on each individual page, you can simply add the redirect code to the .htaccess file.

Here is how to do it:

Create a file on the root directory of your website, name it ".htaccess".
Open the .htaccess file using nano, vim, or what ever text editor that you prefer.
Add the code snippet into the .htaccess file.

NOTE:  The '/' in the snippet is the path (in the context of a browser's address bar) to the original URL. As you are redirecting from the root, that is the location indicated by '/'.

Redirect 301 / http://www.example.com/path/to/new/location.html

Open in new window

0
chrismarxAuthor Commented:
so the $ means just the root?

and what do you instead of virtualhost, i still want to keep that...

i have something like this

# 199.999.999.99
<VirtualHost 199.999.999.99:80>
    DocumentRoot /web/www/x.y.z.edu
    ServerName x.y.z.edu

    ### ERRORS ###
    ErrorDocument 404 /not_found
    ErrorDocument 500 /status/
    ErrorDocument 502 /badgateway/index.html
    ErrorDocument 503 /badgateway/index.html

can i just add your

RedirectMatch 301 ^/$ http://othersite/

why do i need the 301?
0
Ghoti_AZCommented:
The 301 is an HTTP error code used to redirect a browser to a new (or, in your case, correct) location of a web site.  When a client goes to your page, your server will send a 301 with the new URL, and the browser will transparently just go to the correct location.  Caster and I just gave two methods to accomplish the 301 redirect is all; the .htaccess method that I posted, I thought, would be less intrusive to the other sites you alluded to in your original post.
0
caterham_wwwCommented:
> so the $ means just the root?

yes, it terminates the string. redirect 301 / http... will match everything but not RedirectMatch ^/$

> can i just add your

Yes, somewhere between <VirtualHost 199.999.999.99:80> and </Virtualhost>. Order doesn't matter.

> why do i need the 301?

That's the HTTP status code (moves permanently). A 302 status code (that's the default if you omit the status code) is not a good one for search engines (moved temporarily), except you'd like your page contents of http://othersite to appear under http://x.y.z.edu in search engines. That happens with a 302 status code.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
chrismarxAuthor Commented:
thanks!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.