Is is possible to do this in PHP (redirection) ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Star

    Is is possible to do this in PHP (redirection) ?

    Hi,

    I would like to do the following.
    If the user types this URL in the browser:



    I want it to be redirected to http://www.mysite.com/showuser?user=john

    The same if the user types a different name, for example:

    In this case, I want it to be redirected to


    The thing is I don't want to create a different folder for each user.

    Thanks a lot!

  • Ewoud Dronkert

    #2
    Re: Is is possible to do this in PHP (redirection) ?

    On 2 Mar 2005 09:45:56 -0800, Star wrote:[color=blue]
    > http://www.mysite.com/john
    > I want it to be redirected to http://www.mysite.com/showuser?user=john[/color]



    --
    Firefox Web Browser - Rediscover the web - http://getffox.com/
    Thunderbird E-mail and Newsgroups - http://gettbird.com/

    Comment

    • Star

      #3
      Re: Is is possible to do this in PHP (redirection) ?

      Ewoud Dronkert wrote:[color=blue]
      > On 2 Mar 2005 09:45:56 -0800, Star wrote:[color=green]
      > > http://www.mysite.com/john
      > > I want it to be redirected to[/color][/color]
      http://www.mysite.com/showuser?user=john[color=blue]
      >
      > http://httpd.apache.org/docs/misc/rewriteguide.html
      >
      > --
      > Firefox Web Browser - Rediscover the web - http://getffox.com/
      > Thunderbird E-mail and Newsgroups - http://gettbird.com/[/color]


      Thanks for the information. The problem is I don't own that server, so
      I cannot change its internal settings. I just can upload php pages.
      Is there anything that I can do?

      Thanks

      Comment

      • Matt Mitchell

        #4
        Re: Is is possible to do this in PHP (redirection) ?

        "Star" <staryon@hotmai l.com> wrote in message
        news:1109793967 .529765.99830@z 14g2000cwz.goog legroups.com...
        : > http://httpd.apache.org/docs/misc/rewriteguide.html
        :
        : Thanks for the information. The problem is I don't own that server, so
        : I cannot change its internal settings. I just can upload php pages.
        : Is there anything that I can do?

        As long as rewrites are permitted on the server, you can do them using
        ..htaccess files. If they're not permitted, you'll get a 500 error page...

        Some of the stuff on that page is for httpd.conf files, but what you're
        asking about can be done through .htaccess

        Matt


        Comment

        • Star

          #5
          Re: Is is possible to do this in PHP (redirection) ?

          Thanks, Matt. I'll try that.

          Could anybody give an code example of what I need? I checked the page
          that Ewoud Dronkert gave me,
          but I'm very novice with PHP pages, and in that page there are all kind
          of rules and I cannot find the one that I need.

          Thanks a lot.

          Comment

          • Ramius

            #6
            Re: Is is possible to do this in PHP (redirection) ?

            Star wrote:[color=blue]
            > Thanks, Matt. I'll try that.
            >
            > Could anybody give an code example of what I need? I checked the page
            > that Ewoud Dronkert gave me,
            > but I'm very novice with PHP pages, and in that page there are all[/color]
            kind[color=blue]
            > of rules and I cannot find the one that I need.
            >
            > Thanks a lot.[/color]

            I'm a bit of a novice with RewriteRules myself, but I _THINK_ the
            following will work. Your webhost will have to have mod_rewrite and
            allow .htaccess files, but many hosts do. Just place it in a file
            named .htaccess (note the leading dot), and see what happens. Make
            sure you've created a showuser.php file also, of course. Note that
            this does a transparent redirect, that is, the browser URL bar will not
            update with /showuser.php. The redirection occurs silently
            server-side.

            RewriteEngine On
            RewriteBase /
            RewriteRule ^([a-zA-Z])$ /showuser.php?us er=$1 [QSA]

            Comment

            • Star

              #7
              Re: Is is possible to do this in PHP (redirection) ?

              Ramius, thanks for your answer.

              Unfortunately, it doesn't work. I got an 404 error message that says:

              Not Found

              The requested URL /john was not found on this server.

              Any hints?

              Thanks

              Comment

              • Matt Mitchell

                #8
                Re: Is is possible to do this in PHP (redirection) ?

                "Star" <staryon@hotmai l.com> wrote in message
                news:1109879603 .658965.11250@f 14g2000cwb.goog legroups.com...
                : Ramius, thanks for your answer.
                :
                : The requested URL /john was not found on this server.
                :
                : Any hints?
                :

                Put a /showuser.php script on the server!

                Matt


                Comment

                • Star

                  #9
                  Re: Is is possible to do this in PHP (redirection) ?

                  Matt, of course, I have that file on the server.

                  Comment

                  Working...