Jump to content

generate URL


sleith

Recommended Posts

no you would not need to create a sub-directory for each

user, it can be done with .htaccess

 

ex:

RewriteEngine on
RewriteRule ^([^/\.]+)/?$ users.php?user=$1 [L]

 

this will display as:

http://www.website.com/username

 

and send "username" to

users.php as an $_GET variable,

so you can call it with

echo $_GET['user'] in users.php

Link to comment
https://forums.phpfreaks.com/topic/100586-generate-url/#findComment-514455
Share on other sites

no you would not need to create a sub-directory for each

user, it can be done with .htaccess

 

ex:

RewriteEngine on
RewriteRule ^([^/\.]+)/?$ users.php?user=$1 [L]

 

this will display as:

http://www.website.com/username

 

and send "username" to

users.php as an $_GET variable,

so you can call it with

echo $_GET['user'] in users.php

 

Thanks about the info. I'll learn about RewriteEngine

Btw, how about url on subdomain level like thedudeoforkut.multiply.com ?

Link to comment
https://forums.phpfreaks.com/topic/100586-generate-url/#findComment-514473
Share on other sites

Here a little fast example you can also do.......

<?php

$i=array("peeter"=>"00005","paul"=>"00006","harry"=>"00007","john"=>"00008");

foreach($i as $username => $id){

echo"<a href='".$_SERVER['PHP_SELF']."?profile=$username'>$username</a><br><br>";

if($_GET['profile']=="$username"){

switch($username){

case $username:

	echo "your name is $username with id $id <br><br>";

	brake;
}
}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/100586-generate-url/#findComment-514498
Share on other sites

Here a little fast example you can also do.......

<?php

$i=array("peeter"=>"00005","paul"=>"00006","harry"=>"00007","john"=>"00008");

foreach($i as $username => $id){

echo"<a href='".$_SERVER['PHP_SELF']."?username=$username'>$username</a><br><br>";

if($_GET['username']=="$username"){

switch($username){

case $username:

	echo "your name is $username with id $id <br><br>";

	brake;
}
}
}
?>

 

it is to do like "www.xyz.com/username=sleith" right?

i already know that one. i need to directly "sleith.xyz.com"  :P

 

That would work the same way, but then you need to make sure that all subdomains are handled by the same vhost.

Thanks for the info  ;D

Link to comment
https://forums.phpfreaks.com/topic/100586-generate-url/#findComment-514500
Share on other sites

Archived

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

×
×
  • Create New...

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.