Announcement

Collapse
No announcement yet.

redirect directory

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • John Campbell
    replied
    Now this is crazy old but I do have a script that will show users profiles just curious if it was set up the same way as it was talked about back in 01 (using script.php?) how would the file look?

    Thanks.

    Leave a comment:


  • Mark Hensler
    replied
    Code:
    RewriteEngine on
    RewriteCond   /your/docroot/%{REQUEST_FILENAME} !-f
    RewriteRule   ^(.+)                             http://your_domain.com/script.php?user=$1
    the /your/docroot/ needs changed to whatever your document root is. This is the physical path on the machine to where your files are. It will look something like /home/myasl/

    also, the http://your_domain.com/script.php?user=1 needs chagned to to wherever you want to sent people. I'm guessing you want http://myasl.net/script.php?user=$1

    Leave a comment:


  • Jarrod
    replied
    how?

    I dont know how to get maxalberts idea to work, I tried just copying his code straight into the .htaccess file located in the base directory, but it didnt seem to work.
    Is that the code I need to use exactly? or what do i need to change?

    Leave a comment:


  • cditty
    replied
    Did neither of our suggestions work? Max Albert's idea was the best of the two.

    Chris

    Leave a comment:


  • Jarrod
    replied
    experienced?

    any experienced programmers out there got any idea?
    coz I really need to get this done pronto, but I've hit a rut.
    anyone else got some input?
    could i get my host to set a php script as the 404 error by default?

    Leave a comment:


  • Mark Hensler
    replied
    did anyone bother to read docs on Apache?

    I'm no expert (or even close), but this *looks* like it may be what you want... http://httpd.apache.org/docs-2.0/misc/rewriteguide.html
    [look for "Redirect Failing URLs To Other Webserver" about a third of the way down]
    Code:
    RewriteEngine on
    RewriteCond   /your/docroot/%{REQUEST_FILENAME} !-f
    RewriteRule   ^(.+)                             http://your_domain.com/script.php?user=$1
    Good Luck,

    Leave a comment:


  • cditty
    replied
    Did you try $QUERY_STRING? I am using it in one of my scripts. However, I am calling the script name too. ie...http://www.mysite.com/script.php?variable

    Just a thought.

    Chris

    Leave a comment:


  • Jarrod
    replied
    still no luck

    I tried using all the different predefined variables that may hold the requested url data, but none work.
    I think its because the .htaccess file redirects to my redirect.php script, so the REQUESTED_URI variable is showing the path to the redirect.php script.
    Is there any way to get around this, I'm sure there would be, so please help me out.
    Thanx.

    Leave a comment:


  • voicebox
    replied
    Hmm, try putting phpinfo() in the script, which will list all the server's environment variables (as well as a bunch of other goodies). One of those should contain what you want.

    Leave a comment:


  • Jarrod
    replied
    which variable?

    I have done as you said, but I'm not sure on which variable to use to figure out where the visitor wants to go.
    heres my code so far:
    PHP Code:
    $redirect $PATH_INFO;
    echo 
    $redirect
    the $redirect variable is always empty, so i tried using REQUEST_URI, but that just showed the url to the redirect script.
    I also tried HTTP_REFERER, but that came out empty also.

    which variable should I use?
    and then how would I process the variable to get just the end directory name, eg. http://domain.com/bob, then make the variable $dir = "bob".

    any ideas?

    Leave a comment:


  • voicebox
    replied
    I think you can do it with an .htaccess file (put it in your web root):

    ErrorDocument 404 /script.php

    Make the script redirect using $PATH_INFO as the directory requested.

    Leave a comment:


  • Jarrod
    replied
    c'mon

    Yahoo Profiles do it, so i know it can be done, but how?

    c'mon ppl, someone out there must know the answer!

    Leave a comment:


  • Jarrod
    started a topic redirect directory

    redirect directory

    is there any way i can let users type in an url for their homepage like: http://www.myasl.net/$username, but not actually create the dir $username, instead have a script that redirects the user to something like: http://myasl.net/script.php?user=$username

    any help greatly appreciated!

Related Topics

Collapse

Working...
X