Link to home
Start Free TrialLog in
Avatar of hegde123
hegde123

asked on

Apache-PHP question

Hi
  i'd like to know if this scenario is possible and if so how?...We have PHP running on a apache server on port 8080. I'd like to know if its possible to have user come in on a diffrent port, say 8090 which redirects them to a different login page than on port 8080 and have a separate authentication for them using the same web server though.

example: user 1 comes in on 8080 and hits the login page on index.php. This is what currently happens.

I need User 2 to come on on another port 8090 and when so hits a different login page. If its possible to direct them to say index2.php etc.
Avatar of dboeke
dboeke

The simplest way to accomplish this is to create another httpd.conf for the second server, and start a second instance of apache using :

"httpd -f /path/to/other/httpd.conf"

In that conf file, you can specify the second port number and set a different default page in the same document root, or specify a separate document root altogether.

Hope that helps,

David
Avatar of hegde123

ASKER

I'd like to actually do this using the same web server.so basically have one web server access 2 index files depending on which port the user comes in.
in my senario, it is the same web server, you are just starting two instances of it, one listening on each port.

On httpd.conf or .htaccess:

RewriteEngine On
RewriteCond  %{SERVER_PORT}     ^8090
RewriteRule  ^.*$               /path/to/login8090.php

You need mod_rewite, of course.
I didnt tested, but shoud work.


On httpd.conf or .htaccess:

RewriteEngine On
RewriteCond  %{SERVER_PORT}     ^8090
RewriteRule  ^.*$               /path/to/login8090.php

You need mod_rewite, of course.
I didnt tested, but shoud work.

Why can't you create a vertiual host with different post specified . In this configuarion if you header is different site is different and if the port is different then the site is different. It will be easy and will make a another url for you like

www.test.com:8080 is different from with document root /www/8080port/
www.test.com:8090 with document root /www/8090port/

Good Luck
Harry
You can have two "Listen" directives in your apache configuration.  "Listen 8080" and "Listen 8090".  (Two seperate lines.)  Then, in your normal index.php, just check $_SERVER["HTTP_HOST"] to see if it's coming in on port 8080 or port 8090.  Then you can just redirect to index2.php if it's port 8090.  And you don't need to setup any other virtual hosts or directories.

  -- Rob
ASKER CERTIFIED SOLUTION
Avatar of Smada
Smada

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial