Trium918 Posted May 7, 2008 Share Posted May 7, 2008 I would like for the URL to show the user's name or ID number if the user is logged in. How would I accomplish this? Example: www.mysite/profile/user Link to comment https://forums.phpfreaks.com/topic/104625-manipulating-the-url/ Share on other sites More sharing options...
ternto333 Posted May 7, 2008 Share Posted May 7, 2008 www.mysite/profile/user/?user_id=23345&name=user Link to comment https://forums.phpfreaks.com/topic/104625-manipulating-the-url/#findComment-535490 Share on other sites More sharing options...
Trium918 Posted May 7, 2008 Author Share Posted May 7, 2008 www.mysite/profile/user/?user_id=23345&name=user Ok, currently I have www.mysite/profile/index.php showing in the URL, but I would like for the user name or ID number to show in the place of index.php. How would I remove index.php and replace it with the user name? Link to comment https://forums.phpfreaks.com/topic/104625-manipulating-the-url/#findComment-535494 Share on other sites More sharing options...
blackcell Posted May 7, 2008 Share Posted May 7, 2008 I don't think it is possible since the urls last identifier is the file your executing script from. If you really want to show the name/number: <?php <a href='www.mysite/profile/index.php?user=$userNameID'>Link On Previous Page</a> //URL will look something like: www.mysite/profile/index.php?user=Blackcell //or //URL will look something like: www.mysite/profile/index.php?user=05812 ?> Make all of your links look like that. But this can be a security issue if not careful with the information you are passing. If you absolutely want to replace index.php with the name you will have to get into templates and then start with file opening functions and file_exist functions. Link to comment https://forums.phpfreaks.com/topic/104625-manipulating-the-url/#findComment-535497 Share on other sites More sharing options...
Trium918 Posted May 7, 2008 Author Share Posted May 7, 2008 I don't think it is possible since the urls last identifier is the file your executing script from. If you really want to show the name/number: <?php <a href='www.mysite/profile/index.php?user=$userNameID'>Link On Previous Page</a> //URL will look something like: www.mysite/profile/index.php?user=Blackcell //or //URL will look something like: www.mysite/profile/index.php?user=05812 ?> Make all of your links look like that. But this can be a security issue if not careful with the information you are passing. If you absolutely want to replace index.php with the name you will have to get into templates and then start with file opening functions and file_exist functions. I've seen it done on other sites, so I started wondering how could it be done using php. Link to comment https://forums.phpfreaks.com/topic/104625-manipulating-the-url/#findComment-535549 Share on other sites More sharing options...
DarkWater Posted May 7, 2008 Share Posted May 7, 2008 Show me what site. On the PROFILE PAGE is a different story. Not on EVERY page though. Link to comment https://forums.phpfreaks.com/topic/104625-manipulating-the-url/#findComment-535553 Share on other sites More sharing options...
benphp Posted May 7, 2008 Share Posted May 7, 2008 I've seen it done too, but I don't think it's a PHP thing. It's probably set up at the server - Link to comment https://forums.phpfreaks.com/topic/104625-manipulating-the-url/#findComment-535556 Share on other sites More sharing options...
rarebit Posted May 7, 2008 Share Posted May 7, 2008 search for mod_rewrite Link to comment https://forums.phpfreaks.com/topic/104625-manipulating-the-url/#findComment-535558 Share on other sites More sharing options...
DarkWater Posted May 7, 2008 Share Posted May 7, 2008 I know how to make http://www.yoursite.com/profile/username show a profile page for that user... O_O Link to comment https://forums.phpfreaks.com/topic/104625-manipulating-the-url/#findComment-535559 Share on other sites More sharing options...
Trium918 Posted May 7, 2008 Author Share Posted May 7, 2008 Show me what site. On the PROFILE PAGE is a different story. Not on EVERY page though. http://www.thisis50.com/profile/50cent I only want it on the profile page. Link to comment https://forums.phpfreaks.com/topic/104625-manipulating-the-url/#findComment-535561 Share on other sites More sharing options...
DarkWater Posted May 7, 2008 Share Posted May 7, 2008 <IfModule mod_rewrite.c> RewriteEngine On </IfModule> RewriteRule ^profile/([a-zA-Z0-9])$ profile.php?username=$1 RewriteRule ^profile/([a-zA-Z0-9])/$ profile.php?username=$1 Put that in a .htaccess file of your root server directory, and replace profile.php with your profile page name. =P Link to comment https://forums.phpfreaks.com/topic/104625-manipulating-the-url/#findComment-535563 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.