jbog91 Posted July 22, 2006 Share Posted July 22, 2006 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=jbog91I want this:http://www.mysite.com/jbog91I'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. :( Quote Link to comment https://forums.phpfreaks.com/topic/15311-clean-urls/ Share on other sites More sharing options...
localhost Posted July 22, 2006 Share Posted July 22, 2006 on sign up you would have to do use mkdir to make a directory for each $username Quote Link to comment https://forums.phpfreaks.com/topic/15311-clean-urls/#findComment-61983 Share on other sites More sharing options...
wildteen88 Posted July 22, 2006 Share Posted July 22, 2006 Look into mod_rewrite should be able to help here. Quote Link to comment https://forums.phpfreaks.com/topic/15311-clean-urls/#findComment-62041 Share on other sites More sharing options...
jbog91 Posted July 22, 2006 Author Share Posted July 22, 2006 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_rewriteBut it says that if I have:www.mysite.com/profile.php?user=jbog91I would need to have this:www.mysite.com/profile/jbog91What could I do to make it:www.mysite.com/jbog91 Quote Link to comment https://forums.phpfreaks.com/topic/15311-clean-urls/#findComment-62098 Share on other sites More sharing options...
Kurt Posted July 22, 2006 Share Posted July 22, 2006 [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. Quote Link to comment https://forums.phpfreaks.com/topic/15311-clean-urls/#findComment-62101 Share on other sites More sharing options...
wildteen88 Posted July 22, 2006 Share Posted July 22, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/15311-clean-urls/#findComment-62107 Share on other sites More sharing options...
jbog91 Posted July 22, 2006 Author Share Posted July 22, 2006 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=jbog91turn into this:www.mysite.com/jbog91 Quote Link to comment https://forums.phpfreaks.com/topic/15311-clean-urls/#findComment-62152 Share on other sites More sharing options...
wildteen88 Posted July 22, 2006 Share Posted July 22, 2006 Something like this:[code]RewriteEngine OnRewriteRule ^([A-Za-z0-9-]+)$ profile.php?user=$1[/code]Put the htacess file in the root of your websites folderMake sure the mod_rewrite engine is enabled too. Quote Link to comment https://forums.phpfreaks.com/topic/15311-clean-urls/#findComment-62159 Share on other sites More sharing options...
jbog91 Posted July 22, 2006 Author Share Posted July 22, 2006 Thanks. Seems to be working. I'll post back if I have anymore problems. Quote Link to comment https://forums.phpfreaks.com/topic/15311-clean-urls/#findComment-62169 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.