LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Redirection in Apache (https://www.linuxquestions.org/questions/linux-networking-3/redirection-in-apache-288631/)

gonzo22 02-10-2005 03:48 PM

Redirection in Apache
 
Hello,

I need to redirect from Apache to a different directory on the server. This is what I am trying to accomplish

something.com redirected to something.com/someone

The domain name will stay the same just need to pointed a directory deeper.

Thanks,

konrad

BinaryBob 02-11-2005 03:43 AM

Look into another form of redirection. I've never done this directly inside of apache, and its prolly not even the best way to do it. Try, javascript, if you don't want to do it server side. But if you d`want to do it server-side, I'd go with PHP, then you can send the correct HTTP redirection header, and what you want would be carried out.

overlord73 02-11-2005 03:50 AM

..if u want to configure it inside of apache, look for mod_rewrite....or use a script! ;-)

BinaryBob 02-11-2005 04:21 AM

Yeah mod_rewrite will do some crazy stuff, but tricky to configure sometimes. Here's a link to it's config info:
http://httpd.apache.org/docs/misc/rewriteguide.htm

(I strongly recommend, a script method though, like my first post described)

angrybeaver 02-11-2005 04:31 AM

mod_alias will let you add a permenent redirect to wherever you want. Doc for this directive is here .

If you want to redirect your documentroot, your alias will be /

... or you can add a redirect metatag to the HTML source of your index.

<HEAD>
<META HTTP-EQUIV="Refresh" CONTENT="0; URL=someotherurl">
</HEAD>

no crazy php client header management or javascript required... ;)

Either way, the browser needs to refetch the page, so your choice. Having apache handle the redirect is better, as it will redirect *all* requests for that alias. Not just simply on one or two hypertext sources.

but... if its on the same box, why not just adjust your DocumentRoot ?????

secesh 02-12-2005 09:54 AM

in regards to meta refresh, i prefer script alternative... can't remember why i started using these, just that i ran into a problem with a meta refresh somewhere...

though if this is a standing redirect, i would let apache handle it...

Code:

<html>
  <head>
    <title>Redirecting</title>
  </head>
  <body>
    <script type="text/javascript" language="Javascript">
      <!--
      document.location="somewhere.html";
      //-->
    </script>
    <noscript>
      Your mother was a hampster and your father smelt
      of elderberries.
      <a href="somewhere.html">This page has moved</a>
    </noscript>
  </body>
</html>



All times are GMT -5. The time now is 04:02 PM.