Connecting Tech Pros Worldwide Forums | Help | Site Map

the root folder

toufik toufik
Guest
 
Posts: n/a
#1: Jul 17 '05
Hi,
I've a web site in the address http://mySite.com
in the root, I've a file index.html

I've some subfiolders insid root/sub1/sub2

I like to add an html file (or php) index.html that call the index.html of
the root (in order to protect)
Now I've created 2 different index.html because I use relative path to
design the root (../index.html and ../../index.html)

I like to have the same file in all folders,but I don't know how to call the
root folder.
Any help please?
Thanks



Virgil Green
Guest
 
Posts: n/a
#2: Jul 17 '05

re: the root folder


"toufik toufik" <toufiki@sympatico.ca> wrote in message
news:DEghc.12644$CO3.662052@news20.bellglobal.com. ..[color=blue]
> Hi,
> I've a web site in the address http://mySite.com
> in the root, I've a file index.html
>
> I've some subfiolders insid root/sub1/sub2
>
> I like to add an html file (or php) index.html that call the index.html of
> the root (in order to protect)
> Now I've created 2 different index.html because I use relative path to
> design the root (../index.html and ../../index.html)
>
> I like to have the same file in all folders,but I don't know how to call[/color]
the[color=blue]
> root folder.
> Any help please?[/color]

Are you trying to include the file or create a link to it? That is quite
unclear.

- Virgil


toufik toufik
Guest
 
Posts: n/a
#3: Jul 17 '05

re: the root folder


Thanks.

I like to call the file:

<body onload="document.location.href='../../index.html';">



"Virgil Green" <vjg@obsydian.com> wrote in message
news:QShhc.19477$CN2.13342@newssvr22.news.prodigy. com...[color=blue]
> "toufik toufik" <toufiki@sympatico.ca> wrote in message
> news:DEghc.12644$CO3.662052@news20.bellglobal.com. ..[color=green]
> > Hi,
> > I've a web site in the address http://mySite.com
> > in the root, I've a file index.html
> >
> > I've some subfiolders insid root/sub1/sub2
> >
> > I like to add an html file (or php) index.html that call the index.html[/color][/color]
of[color=blue][color=green]
> > the root (in order to protect)
> > Now I've created 2 different index.html because I use relative path to
> > design the root (../index.html and ../../index.html)
> >
> > I like to have the same file in all folders,but I don't know how to call[/color]
> the[color=green]
> > root folder.
> > Any help please?[/color]
>
> Are you trying to include the file or create a link to it? That is quite
> unclear.
>
> - Virgil
>
>[/color]


Pertti Kosunen
Guest
 
Posts: n/a
#4: Jul 17 '05

re: the root folder


"toufik toufik" <toufiki@sympatico.ca> wrote in message
news:DEghc.12644$CO3.662052@news20.bellglobal.com. ..[color=blue]
> Hi,
> I've a web site in the address http://mySite.com
> in the root, I've a file index.html
>
> I've some subfiolders insid root/sub1/sub2
>
> I like to add an html file (or php) index.html that call the index.html of
> the root (in order to protect)
> Now I've created 2 different index.html because I use relative path to
> design the root (../index.html and ../../index.html)
>
> I like to have the same file in all folders,but I don't know how to call[/color]
the[color=blue]
> root folder.[/color]

If you want sub1/index.php and other subN/index.php to redirect to root, use
header function.

<?php
header("Location: http://mysite.com/index.html"); /* Redirect browser */

/* Make sure that code below does not get executed when we redirect. */
exit;
?>


toufik toufik
Guest
 
Posts: n/a
#5: Jul 17 '05

re: the root folder


Thanks.
I don't like to use http://mysite in my call, because I can install my
solution in differant location,
http://mysite1
http://mysite2......

And I like that the code works in all situations

Thanks.

"Pertti Kosunen" <pertti.kosunen@kolumb.us.fi_invalid> wrote in message
news:c65omk$saq$1@phys-news1.kolumbus.fi...[color=blue]
> "toufik toufik" <toufiki@sympatico.ca> wrote in message
> news:DEghc.12644$CO3.662052@news20.bellglobal.com. ..[color=green]
> > Hi,
> > I've a web site in the address http://mySite.com
> > in the root, I've a file index.html
> >
> > I've some subfiolders insid root/sub1/sub2
> >
> > I like to add an html file (or php) index.html that call the index.html[/color][/color]
of[color=blue][color=green]
> > the root (in order to protect)
> > Now I've created 2 different index.html because I use relative path to
> > design the root (../index.html and ../../index.html)
> >
> > I like to have the same file in all folders,but I don't know how to call[/color]
> the[color=green]
> > root folder.[/color]
>
> If you want sub1/index.php and other subN/index.php to redirect to root,[/color]
use[color=blue]
> header function.
>
> <?php
> header("Location: http://mysite.com/index.html"); /* Redirect browser */
>
> /* Make sure that code below does not get executed when we redirect. */
> exit;
> ?>
>
>[/color]


Virgil Green
Guest
 
Posts: n/a
#6: Jul 17 '05

re: the root folder


"toufik toufik" <toufiki@sympatico.ca> wrote in message
news:8_hhc.12952$CO3.677019@news20.bellglobal.com. ..[color=blue]
> Thanks.
>
> I like to call the file:
>
> <body onload="document.location.href='../../index.html';">[/color]

You can always access the root index.html just by using "/index.html".

- Virgil


Pertti Kosunen
Guest
 
Posts: n/a
#7: Jul 17 '05

re: the root folder


"toufik toufik" <toufiki@sympatico.ca> wrote in message
news:l3vhc.15310$CO3.827694@news20.bellglobal.com. ..[color=blue]
> Thanks.
> I don't like to use http://mysite in my call, because I can install my
> solution in differant location,
> http://mysite1
> http://mysite2......
>
> And I like that the code works in all situations[/color]

http://fi2.php.net/manual/en/function.header.php

You can use $_SERVER['HTTP_HOST'].

<?php
header("Location: http://" . $_SERVER['HTTP_HOST'] . "/");
?>


Jan Pieter Kunst
Guest
 
Posts: n/a
#8: Jul 17 '05

re: the root folder


In article <l3vhc.15310$CO3.827694@news20.bellglobal.com>,
"toufik toufik" <toufiki@sympatico.ca> wrote:
[color=blue]
> Thanks.
> I don't like to use http://mysite in my call, because I can install my
> solution in differant location,
> http://mysite1
> http://mysite2......
>
> And I like that the code works in all situations
>
> Thanks.[/color]

Then you can do this:

header('Location: http://' . $_SERVER['HTTP_HOST'] . '/index.html');

JP

--
Sorry, <devnull@cauce.org> is een "spam trap".
E-mail adres is <jpk"at"akamail.com>, waarbij "at" = @.
Oliver Grätz
Guest
 
Posts: n/a
#9: Jul 17 '05

re: the root folder


toufik toufik schrieb:[color=blue]
> Hi,
> I've a web site in the address http://mySite.com
> in the root, I've a file index.html
>
> I've some subfiolders insid root/sub1/sub2
>
> I like to add an html file (or php) index.html that call the index.html of
> the root (in order to protect)
> Now I've created 2 different index.html because I use relative path to
> design the root (../index.html and ../../index.html)
>
> I like to have the same file in all folders,but I don't know how to call the
> root folder.[/color]

You could do a redirect:

$domain=$_SERVER['HTTP_HOST'];
header("Location: http://$domain/index.html");

Or simply include it with this index.php:

<?php include('/index.html'); ?>

The second solution creates a problem with files included by the
index.html, because all the relative paths have changed. Any pictures or
JavaScripts have to be referenced by absolute URL. If this is OK for
you, use the include, because it should be a bit quicker.



AllOlli
Virgil Green
Guest
 
Posts: n/a
#10: Jul 17 '05

re: the root folder


"Oliver Grätz" <oliver.graetz@gmx.de> wrote in message
news:40878b7b$0$15488$9b4e6d93@newsread4.arcor-online.net...[color=blue]
> toufik toufik schrieb:[color=green]
> > Hi,
> > I've a web site in the address http://mySite.com
> > in the root, I've a file index.html
> >
> > I've some subfiolders insid root/sub1/sub2
> >
> > I like to add an html file (or php) index.html that call the index.html[/color][/color]
of[color=blue][color=green]
> > the root (in order to protect)
> > Now I've created 2 different index.html because I use relative path to
> > design the root (../index.html and ../../index.html)
> >
> > I like to have the same file in all folders,but I don't know how to call[/color][/color]
the[color=blue][color=green]
> > root folder.[/color]
>
> You could do a redirect:
>
> $domain=$_SERVER['HTTP_HOST'];
> header("Location: http://$domain/index.html");
>
> Or simply include it with this index.php:
>
> <?php include('/index.html'); ?>[/color]

This most likely will *not* work as the include paths are system paths, not
paths from the webroot.

- Virgil


Oliver Grätz
Guest
 
Posts: n/a
#11: Jul 17 '05

re: the root folder


Virgil Green schrieb:[color=blue][color=green]
>><?php include('/index.html'); ?>[/color]
>
> This most likely will *not* work as the include paths are system paths, not
> paths from the webroot.
>[/color]

Oh, total blackout on my side. Yes, it certainly won't work unless you
have your own server and use a chroot-environment like I do...

AllOLLi


Closed Thread