Jump to content

Archived

This topic is now archived and is closed to further replies.

jbog91

Clean URLs

Recommended Posts

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.com/profile.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. :(

Share this post


Link to post
Share on other sites
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.workingwith.me.uk/articles/scripting/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

Share this post


Link to post
Share on other sites
[quote author=jbog91 link=topic=101446.msg401701#msg401701 date=1153587349]
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?
[/quote]
Just make a .htaccess file.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Something like this:
[code]RewriteEngine On

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

Make sure the mod_rewrite engine is enabled too.

Share this post


Link to post
Share on other sites
Thanks. Seems to be working. I'll post back if I have anymore problems.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.