npsari Posted November 20, 2007 Share Posted November 20, 2007 Hi there, I have a community website At the moment, the way of seeing a user's profile is ... http://www.example.com/users.php?user=7 But now, I want users to have a real link http://www.example.com/sara Like Myspace does, which allows you to choose an URL How does a website do that, do i create folders for users in my public folder directory is that how it is done? What if there is thousands of users... Will i end up having thousands of folders in my public directory So, Myspace has billions of folders then Can you tell me how this is done Quote Link to comment https://forums.phpfreaks.com/topic/78124-solved-creating-urls-for-users-in-my-site/ Share on other sites More sharing options...
thebadbad Posted November 20, 2007 Share Posted November 20, 2007 You should be able to find plenty of so called mod rewrite topics around here. It's an Apache (server) thing. Quote Link to comment https://forums.phpfreaks.com/topic/78124-solved-creating-urls-for-users-in-my-site/#findComment-395353 Share on other sites More sharing options...
sstangle73 Posted November 20, 2007 Share Posted November 20, 2007 heres a nice wizzard to help you with mod rewrite its not perfect but it helps http://www.mod-rewrite-wizard.com/ Quote Link to comment https://forums.phpfreaks.com/topic/78124-solved-creating-urls-for-users-in-my-site/#findComment-395354 Share on other sites More sharing options...
npsari Posted November 20, 2007 Author Share Posted November 20, 2007 Ohh, you mean this MOD rewrite is what iam looking for So, the way is not to create a directiory for each user Quote Link to comment https://forums.phpfreaks.com/topic/78124-solved-creating-urls-for-users-in-my-site/#findComment-395358 Share on other sites More sharing options...
sstangle73 Posted November 20, 2007 Share Posted November 20, 2007 noo thats what i thought at 1st also then i learned about mod rewrite it is bassed off gets so what the url is really is http://www.example.com/users.php?user=7 but the users see http://www.example.com/sara look at my site. http://stangle.info/sstangle73 shows my profile also this will http://stangle.info/profile.php?username=sstangle73 Quote Link to comment https://forums.phpfreaks.com/topic/78124-solved-creating-urls-for-users-in-my-site/#findComment-395360 Share on other sites More sharing options...
npsari Posted November 20, 2007 Author Share Posted November 20, 2007 Your website looks cool, but it asks me to register so i can see that page, well, i might register to see whats crackin there anyway, thanks for the info I will try to study theis MOD thing, and see what happens from there But that site looks like a software or something, http://www.mod-rewrite-wizard.com/ isnt there like a php script which i can use Quote Link to comment https://forums.phpfreaks.com/topic/78124-solved-creating-urls-for-users-in-my-site/#findComment-395364 Share on other sites More sharing options...
redarrow Posted November 20, 2007 Share Posted November 20, 2007 a guess RewriteEngine On RewriteBase / RewriteRule ^(.+)/([a-z]+)/?$ http://www.example.com/users.php?username=$_GET['username'] Quote Link to comment https://forums.phpfreaks.com/topic/78124-solved-creating-urls-for-users-in-my-site/#findComment-395372 Share on other sites More sharing options...
npsari Posted November 20, 2007 Author Share Posted November 20, 2007 The problem is that this website and i think the code you gave me now end the URL with .html or .php So, it becomes something like: http://www.example.com/sara.html It looks wrong Do you know why this is the way It has to end with the name only Quote Link to comment https://forums.phpfreaks.com/topic/78124-solved-creating-urls-for-users-in-my-site/#findComment-395377 Share on other sites More sharing options...
trq Posted November 20, 2007 Share Posted November 20, 2007 The mod_rewrite should look like.... RewriteEngine On RewriteBase / RewriteRule ^(.*)$ users.php?user=$1 [L] Quote Link to comment https://forums.phpfreaks.com/topic/78124-solved-creating-urls-for-users-in-my-site/#findComment-395382 Share on other sites More sharing options...
npsari Posted November 20, 2007 Author Share Posted November 20, 2007 Just to clarify somethings from my side That code you gave me should be between php tags? <? RewriteEngine On RewriteBase / RewriteRule ^(.*)$ users.php?user=$1 [L] ?> and where is the part where i identify $1 Is there a link which i can read about all that stuff guys Quote Link to comment https://forums.phpfreaks.com/topic/78124-solved-creating-urls-for-users-in-my-site/#findComment-395388 Share on other sites More sharing options...
sstangle73 Posted November 20, 2007 Share Posted November 20, 2007 this goes in the .htaccess sp? file google mod rewrite youll find some nice tuts thats how i learned it google is your friend! Quote Link to comment https://forums.phpfreaks.com/topic/78124-solved-creating-urls-for-users-in-my-site/#findComment-395393 Share on other sites More sharing options...
trq Posted November 20, 2007 Share Posted November 20, 2007 The code I gave you is not php. It is some apache directives that setup a mod_rewrite rule. You need to place those lines in your .htaccess file if you have one, or create the file if you don't. You need to read up on mod_rewrite to find out more. Quote Link to comment https://forums.phpfreaks.com/topic/78124-solved-creating-urls-for-users-in-my-site/#findComment-395395 Share on other sites More sharing options...
trq Posted November 20, 2007 Share Posted November 20, 2007 I should add. Given an address like http://yoursite.com/foo , the username foo will show up in $_GET['user'] within the users.php file. Quote Link to comment https://forums.phpfreaks.com/topic/78124-solved-creating-urls-for-users-in-my-site/#findComment-395399 Share on other sites More sharing options...
npsari Posted November 20, 2007 Author Share Posted November 20, 2007 Ok, thanks guys I dont understand much still, but it is fair that i try myself to understand it at least i know the name now mod_rewrite i will google it!! Quote Link to comment https://forums.phpfreaks.com/topic/78124-solved-creating-urls-for-users-in-my-site/#findComment-395401 Share on other sites More sharing options...
trq Posted November 20, 2007 Share Posted November 20, 2007 I posted a link to the manual page. Quote Link to comment https://forums.phpfreaks.com/topic/78124-solved-creating-urls-for-users-in-my-site/#findComment-395403 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.