Jump to content

Recommended Posts

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

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

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

<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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.