Page 1 of 1

Redirect only on one site from specific url

PostPosted: 23. March 2009 15:02
by jashimili
I don't know how to exactly explain what i need but i will try.
here is problem.
i bought domain, but i am using xampp and my computer for hosting.

on default if someone enter my ip it will open xampp site in htdocs/xampp,
this config is writen in htdocs/index.php file
<?php
if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) {
$uri = 'https://';
} else {
$uri = 'http://';
}
$uri .= $_SERVER['HTTP_HOST'];
header('Location: '.$uri.'/xampp/');
exit;
?>

i changed $uri.'/xampp/' into $uri.'/name of my site/'

and it works, so when someone enter "name of my site.com" or my ip it will open site that i wanted.

but it will open like this "name of my site.com/name of my site" or my ip/name of my site.
and if someone type "name of my site.com/xampp" or "name of my site.com/another site" it will open different site.(site what is in htdocs folder behind that slash.)

because now i need xampp to host another site, and to forbid that type of access, how i can do something like this:
if someone type
"nameofmysite.com" to open htdocs/nameofmysite and to show to user address like "nameofmysite.com"
and if someone type
"nameofmysite.com/anothersite" to show him access denied or invalid url, but if he type some existing sub folder of my site for example "nameofmysite.com/category" to show him category of products of that site on that domain.

but i still need to have access from another domain to another site, something like:
"anothersite.com" to show him this another site.

i think this is called virtual hosting?

just to notify im on lan and i have static ip on lan, but i have access on wan through mikrotik who gain access through my isp adsl router and there on wan i have dynamic ip, but i am using some dns tool that domain seller give me to keep connection alive with my domain name. i know it is complicated but i live in crappy country.
so any help possible?

Re: Redirect only on one site from specific url

PostPosted: 23. March 2009 15:07
by Wiedmann
if someone type "nameofmysite.com" to open htdocs/nameofmysite and to show to user address like "nameofmysite.com" and if someone type "nameofmysite.com/anothersite" to show him access denied or invalid url, but if he type some existing sub folder of my site for example "nameofmysite.com/category" to show him category of products of that site on that domain.

Just delete all (files and folders) in htdocs (execpt xampp if you need this), and put your files directly in htdocs.

Re: Redirect only on one site from specific url

PostPosted: 23. March 2009 15:19
by jashimili
and then what?
in images folders will be images from both sites, in forum folder will be both forums, and pages from both sites will be in same folder all will mess up, how to put both index files in same folder?

i think this is not solution, any other way?

Re: Redirect only on one site from specific url

PostPosted: 23. March 2009 15:39
by Wiedmann
and then what?

Ah you are right. I have not read this statement:
[quote=jashimili"]but i still need to have access from another domain to another site, something like: "anothersite.com" to show him this another site.[/quote]
configure:
- a (namebased) vhost for ServerName "localhost", DocumentRoot "/xampp/htocs/"

- an additional vhost for ServerName "nameofmysite.com", DocumentRoot "/xampp/htocs/nameofmysite/"

- and an additional vhost for ServerName "anothersite.com", DocumentRoot "/xampp/htocs/anothersite/"

(You can really find 1000 posts in our forum, how to setup vhosts. Just search for it.)

Re: Redirect only on one site from specific url

PostPosted: 23. March 2009 17:12
by jashimili
yes yes this is virtual hosting i wasn't sure but now i fixed this. thanks for point me in right direction :)