Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Help! How do I get the current domain?

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Help! How do I get the current domain?

Postby mpgalvin » Wed Sep 17, 2003 9:27 am

I'm trying to create a sort of community thingy with php. Basically, each user will have their own area on my domain. Now the prob is that they will all share the same mysql db and I use a company_id to determine who is who.

I could quite easily work this with http://www.domain.com/index.php?companyid=1, but I want it to be completely transparent, so the URL will be something along the lines of http://www.domain.com/company1/index.php.

So I'd like to extract the URL to a string and parse it, getting 'company1' (or whatever) out, then look that up in a table to get the company id. Probably not the most efficient way of doing things, but if anyone can help me out here, I'd be very pleased
mpgalvin
New php-forum User
New php-forum User
 
Posts: 12
Joined: Sun Jan 12, 2003 2:53 am

Postby swirlee » Wed Sep 17, 2003 1:52 pm

Assuming you're using Apache (you really should), try this guide to using mod_rewrite: mod_rewrite: A Beginner's Guide to URL Rewriting.
User avatar
swirlee
Moderator
Moderator
 
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back

sessions

Postby ruturajv » Wed Sep 17, 2003 9:00 pm

use sessions!!!!
User avatar
ruturajv
php-forum Super User
php-forum Super User
 
Posts: 1280
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India

Re: sessions

Postby mpgalvin » Thu Sep 18, 2003 3:34 am

ruturajv wrote:use sessions!!!!

Great! how? :D
Actually, I don't see how sessions would work.

The mod_rewrite seems like a good solution, but I can't do it just yet: I'm using Apache, but on a Win machine for development. It means that I have to leave this rather important detail until I've got my domain sorted out.

Isn't there no easier way? Is the posix_uname function any use? Does anyone know how to use it?
mpgalvin
New php-forum User
New php-forum User
 
Posts: 12
Joined: Sun Jan 12, 2003 2:53 am

Re: sessions

Postby swirlee » Thu Sep 18, 2003 12:21 pm

mpgalvin wrote:
ruturajv wrote:use sessions!!!!

Great! how? :D
Actually, I don't see how sessions would work.


Neither do I. ruturajv tends to confuse. Moving along...

mpgalvin wrote:The mod_rewrite seems like a good solution, but I can't do it just yet: I'm using Apache, but on a Win machine for development.


So am I. It works fantastic. Give it a try.
User avatar
swirlee
Moderator
Moderator
 
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back

Postby mpgalvin » Fri Sep 19, 2003 10:25 am

Well, I finally got mod_rewrite up and going (that link you supplied is slightly out of date, by the way - the AddModule directive is not in the version of Apache I have (v2.0.40)

Now, all I have to do is to figure out what the flamin' rules are :) fun!
mpgalvin
New php-forum User
New php-forum User
 
Posts: 12
Joined: Sun Jan 12, 2003 2:53 am


Return to PHP coding => General

Who is online

Users browsing this forum: Exabot [Bot] and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.