Professional Web Applications Themes

some kind of redirection (not the header function) - PHP Development

Hi!!! I´m programming a site in PHP, where I want to do the following: I will have a set of different directories, where each directory must execute the same PHP pages, but giving as result different data, according to the directory where you are located (obtained by $_SERVER[´PHP_SELF´] for example). For example I have: [url]http://www.domain.com/directoryA/[/url] [url]http://www.doamin.com/directoryB/[/url] So each one must have (or should act as if they had) the same PHP pages and directories under them. The solution I thought, as copying each page in every directory makes no sense (if I modify the code I´ll have to change all ...

  1. #1

    Default some kind of redirection (not the header function)

    Hi!!!

    I´m programming a site in PHP, where I want to do the following:

    I will have a set of different directories, where each directory must
    execute the same PHP pages, but giving as result different data,
    according to the directory where you are located (obtained by
    $_SERVER[´PHP_SELF´] for example).

    For example I have:

    [url]http://www.domain.com/directoryA/[/url]
    [url]http://www.doamin.com/directoryB/[/url]

    So each one must have (or should act as if they had) the same PHP pages
    and directories under them.

    The solution I thought, as copying each page in every directory makes no
    sense (if I modify the code I´ll have to change all the pages in all
    directories), is to have an includes directory. where I put all the PHP
    pages, and in each of the different directories I create pages that
    simply include or require the ones from the include directories.

    That way I´ll only modify code inone place..

    Now.. is there any better way to achieve this??
    I thought that maybe with some Apache stuff, but I don´t think there¶
    something that will help, since directives such as RedirectMatch, etc.
    rewrite the URL, and I don´t want that, I want the URL to remain
    [url]http://www.domain.com/directoryX/whatever.php[/url]

    Is there any way to do this, or I should stick up with the includes??

    Thnx in advance,

    Juan
    Juan Nin Guest

  2. #2

    Default Re: [PHP] some kind of redirection (not the header function)


    Is there any type of criteria that would point a user to directoryA or
    directoryB?

    I recently rebuilt a site that handled a couple thousand
    different working directories for clients but used only one set of
    scripts for all. The user would have to login and variables were pulled
    from a database to set the directory that they would work in. The
    directory name could be passed from script to script or stored in
    sessions.

    Ed



    On Thu, 11 Sep 2003, Juan Nin wrote:
    > Hi!!!
    >
    > I´m programming a site in PHP, where I want to do the following:
    >
    > I will have a set of different directories, where each directory must
    > execute the same PHP pages, but giving as result different data,
    > according to the directory where you are located (obtained by
    > $_SERVER[´PHP_SELF´] for example).
    >
    > For example I have:
    >
    > [url]http://www.domain.com/directoryA/[/url]
    > [url]http://www.doamin.com/directoryB/[/url]
    >
    > So each one must have (or should act as if they had) the same PHP pages
    > and directories under them.
    >
    > The solution I thought, as copying each page in every directory makes no
    > sense (if I modify the code I´ll have to change all the pages in all
    > directories), is to have an includes directory. where I put all the PHP
    > pages, and in each of the different directories I create pages that
    > simply include or require the ones from the include directories.
    >
    > That way I´ll only modify code inone place..
    >
    > Now.. is there any better way to achieve this??
    > I thought that maybe with some Apache stuff, but I don´t think there¶
    > something that will help, since directives such as RedirectMatch, etc.
    > rewrite the URL, and I don´t want that, I want the URL to remain
    > [url]http://www.domain.com/directoryX/whatever.php[/url]
    >
    > Is there any way to do this, or I should stick up with the includes??
    >
    > Thnx in advance,
    >
    > Juan
    >
    > --
    > PHP General Mailing List ([url]http://www.php.net/[/url])
    > To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]
    >
    Ed Curtis Guest

  3. #3

    Default Re: [PHP] some kind of redirection (not the header function)

    On Thu, 2003-09-11 at 15:39, Ed Curtis wrote:
    > Is there any type of criteria that would point a user to directoryA or
    > directoryB?
    >
    > I recently rebuilt a site that handled a couple thousand
    > different working directories for clients but used only one set of
    > scripts for all. The user would have to login and variables were pulled
    > from a database to set the directory that they would work in. The
    > directory name could be passed from script to script or stored in
    > sessions.
    The beheaviour I want to acomplish is the same as in yahoorgoups.

    You can access a mian page, where you login and have a list of all the groups you are subscribe to.
    You click on the link to each one and it redirects you to: [url]http://groups./groups/yourGroup/[/url]

    There it displays the page for your group with all it´s characteristics. The same behaviour
    if you access that URL directly. Or you can also access [url]http://groups./groups/yourGroup/messages/[/url] etc

    That¶ what I ant to do :)

    Any ideas?

    thnx again,

    Juan
    Juan Nin Guest

  4. #4

    Default Re: [PHP] some kind of redirection (not the header function)


    I'm pretty sure that YahooGroups uses cookies for this to hold values
    while you're not on their site. When you return it checks for the cookies
    and reloads the values from the last visit. You can accomplish this with
    PHP as well.

    Ed

    On Thu, 11 Sep 2003, Juan Nin wrote:
    > On Thu, 2003-09-11 at 15:39, Ed Curtis wrote:
    > > Is there any type of criteria that would point a user to directoryA or
    > > directoryB?
    > >
    > > I recently rebuilt a site that handled a couple thousand
    > > different working directories for clients but used only one set of
    > > scripts for all. The user would have to login and variables were pulled
    > > from a database to set the directory that they would work in. The
    > > directory name could be passed from script to script or stored in
    > > sessions.
    >
    > The beheaviour I want to acomplish is the same as in yahoorgoups.
    >
    > You can access a mian page, where you login and have a list of all the groups you are subscribe to.
    > You click on the link to each one and it redirects you to: [url]http://groups./groups/yourGroup/[/url]
    >
    > There it displays the page for your group with all it´s characteristics. The same behaviour
    > if you access that URL directly. Or you can also access [url]http://groups./groups/yourGroup/messages/[/url] etc
    >
    > That¶ what I ant to do :)
    >
    > Any ideas?
    >
    > thnx again,
    >
    > Juan
    >
    > --
    > PHP General Mailing List ([url]http://www.php.net/[/url])
    > To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]
    >
    Ed Curtis Guest

  5. #5

    Default Re: [PHP] some kind of redirection (not the header function)

    On Thu, 2003-09-11 at 16:04, Ed Curtis wrote:
    > I'm pretty sure that YahooGroups uses cookies for this to hold values
    > while you're not on their site. When you return it checks for the cookies
    > and reloads the values from the last visit. You can accomplish this with
    > PHP as well.
    that´s clear, I know that, but that¶ not what I want...

    I mean, the thing is that I want to execute the same PHP scripts, no matter what directory I´m in, but
    show data according to what directory I´m in, exactly the same that happens with yahoogroups and it´s groups

    that´s why I´m thinking in putting the PHP pages in each directory which just include the common PHPs
    from an include directory (could use hard links either, but I prefer doing it via PHP and not depend on Os stuff)

    so that´s what I´m asking, if there´s a better way to achieve this, not talking about cookies :)

    Juan
    Juan Nin Guest

  6. #6

    Default Re: [PHP] some kind of redirection (not the header function)

    On Thu, 2003-09-11 at 16:20, Peter James wrote:
    > mod_rewrite allows you to do internal redirects. This would keep your
    > user's URL the same, but actually point to a different page internally.
    > This is, of course, depends on whether you or your host have mod_rewrite
    > installed.
    cool, it was the first thing I had thought off, but after giving a quick
    look at it I thought it rewrited the URLs...

    I´ll take a better look at it!!!
    Thanks!!!

    I guess there´s no way to do something like this only with PHP, without
    Apache conf, is there?

    thnx again,

    Juan
    Juan Nin Guest

  7. #7

    Default Re: some kind of redirection (not the header function)

    Hi Juan,

    You might want to Google for "mod_rewrite tutorial" - this is a fairly
    standard (nowadays) module for Apache. There are a lot of good
    articles, I think I saw a few on [url]http://www.sitepoint.com[/url].

    This isn't the same as a redirect. It rewrites the URL request before
    PHP gets it. So, you could have a request for
    "http://mydomain.com/a/a.php" and mod_rewrite will change it to
    "http://mydomain.com?a=a.php" (or whatever) before PHP ever "sees" the
    URL. Note that you have to write your PHP to output the desired URLs
    on the way OUT - you could use an output buffer to achieve this...


    Good Luck!

    Leonard
    [url]http://www.perceptus.ca[/url]



    On Thu, 11 Sep 2003 15:34:50 -0300, [email]juaidjuanin.com[/email] (Juan Nin) wrote:
    >Hi!!!
    >
    >I´m programming a site in PHP, where I want to do the following:
    >
    >I will have a set of different directories, where each directory must
    >execute the same PHP pages, but giving as result different data,
    >according to the directory where you are located (obtained by
    >$_SERVER[´PHP_SELF´] for example).
    >
    >For example I have:
    >
    >[url]http://www.domain.com/directoryA/[/url]
    >[url]http://www.doamin.com/directoryB/[/url]
    >
    >So each one must have (or should act as if they had) the same PHP pages
    >and directories under them.
    >
    >The solution I thought, as copying each page in every directory makes no
    >sense (if I modify the code I´ll have to change all the pages in all
    >directories), is to have an includes directory. where I put all the PHP
    >pages, and in each of the different directories I create pages that
    >simply include or require the ones from the include directories.
    >
    >That way I´ll only modify code inone place..
    >
    >Now.. is there any better way to achieve this??
    >I thought that maybe with some Apache stuff, but I don´t think there¶
    >something that will help, since directives such as RedirectMatch, etc.
    >rewrite the URL, and I don´t want that, I want the URL to remain
    >[url]http://www.domain.com/directoryX/whatever.php[/url]
    >
    >Is there any way to do this, or I should stick up with the includes??
    >
    >Thnx in advance,
    >
    >Juan
    Leonard Guest

Similar Threads

  1. #25890 [Com]: Strange behaviour of header() function
    By cysgwr_eryri at yahoo dot co dot uk in forum PHP Development
    Replies: 0
    Last Post: October 17th, 08:53 AM
  2. #25890 [Opn->Bgs]: Strange behaviour of header() function
    By iliaa@php.net in forum PHP Development
    Replies: 0
    Last Post: October 17th, 12:58 AM
  3. #25890 [NEW]: Strange behaviour of header() function
    By cysgwr_eryri at yahoo dot dot dot co dot dot dot uk in forum PHP Development
    Replies: 0
    Last Post: October 16th, 04:17 PM
  4. header() redirection/session variable problem
    By Nick Whitelegg in forum PHP Development
    Replies: 1
    Last Post: September 17th, 07:39 PM
  5. #25039 [Fbk->Opn]: system function cause header error / IIS6.0
    By sadun at isikun dot org in forum PHP Development
    Replies: 0
    Last Post: August 11th, 04:14 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139