Jump to content


Photo

Clean URLs


  • Please log in to reply
8 replies to this topic

#1 jbog91

jbog91
  • Members
  • PipPip
  • Member
  • 24 posts

Posted 22 July 2006 - 03:09 AM

I'm working on this site, a community of sort, and I need some help with something I saw on some other sites. I want people to be able to access their profile by typing this is.

Instead of this:

http://www.mysite.co...php?user=jbog91

I want this:
http://www.mysite.com/jbog91

I've seen many things on this but I can't seem to figure it out. I don't own the server, it's going to be shared hosting. :(

#2 localhost

localhost
  • Members
  • PipPipPip
  • Advanced Member
  • 152 posts

Posted 22 July 2006 - 06:12 AM

on sign up you would have to do use mkdir to make a directory for each $username

#3 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 22 July 2006 - 12:30 PM

Look into mod_rewrite should be able to help here.

#4 jbog91

jbog91
  • Members
  • PipPip
  • Member
  • 24 posts

Posted 22 July 2006 - 04:55 PM

I know you don't have to make a directory everytime someone signs up. Doesn't mod_rewrite require you to have access to some apache files that only the server admin has access too?

--Edit--
I see. Mod_rewrite doesn't require you to have access to your server's httpd.conf file. You do it through .htaccess files. I found a tutorial here.

http://www.workingwi...ing/mod_rewrite

But it says that if I have:
www.mysite.com/profile.php?user=jbog91

I would need to have this:
www.mysite.com/profile/jbog91

What could I do to make it:
www.mysite.com/jbog91

#5 Kurt

Kurt
  • Members
  • PipPipPip
  • Advanced Member
  • 42 posts
  • LocationNew York

Posted 22 July 2006 - 05:07 PM

I know you don't have to make a directory everytime someone signs up. Doesn't mod_rewrite require you to have access to some apache files that only the server admin has access too?

Just make a .htaccess file.

#6 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 22 July 2006 - 05:18 PM

You dont need the actual main servers config files, but you can a files called .htaccess files, which most hosts allow you to use anyway.

#7 jbog91

jbog91
  • Members
  • PipPip
  • Member
  • 24 posts

Posted 22 July 2006 - 07:09 PM

I've figured that out. Look at the edit I made. What would I need to put in the file to make this:

www.mysite.com/profile.php?user=jbog91

turn into this:

www.mysite.com/jbog91

#8 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 22 July 2006 - 07:34 PM

Something like this:
RewriteEngine On

RewriteRule ^([A-Za-z0-9-]+)$ profile.php?user=$1
Put the htacess file in the root of your websites folder

Make sure the mod_rewrite engine is enabled too.

#9 jbog91

jbog91
  • Members
  • PipPip
  • Member
  • 24 posts

Posted 22 July 2006 - 08:05 PM

Thanks. Seems to be working. I'll post back if I have anymore problems.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users