CloudSex13 Posted November 20, 2010 Share Posted November 20, 2010 Hi, I've been searching the web for a way to make the mod-rewrite rule work with custom URL's that the user picks. I found one to shorten the page to just the user ID... RewriteEngine On RewriteRule ^([^/]*)$ /userprofile.php?userid=$1 [L] ...but I was hoping to get it to work with a custom URL a user has picked. For example, a user's profile link is userprofile.php?userid=1001. They've picked "example" to be their custom URL, so the URL now would be www.example.com/example, which be a mask for userprofile.php?userid=1001. This custom URL they picked would be stored in the database under their account. Would anyone have any ideas? Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/219307-mod-rewrite-rule-for-custom-urls-userprofilephpuserid1001-to-example/ Share on other sites More sharing options...
trq Posted November 20, 2010 Share Posted November 20, 2010 Your question isn't any longer mod_rewrite related. All you need do is (within profile.php) look up the users profile data by this custom URL the user has picked. eg; if (isset($_GET['id'])) { $id = mysql_real_escape_string($_GET['id']); $sql = "SELECT userdetails FROM users WHERE custom_id = '$id'"; // now execute your query and make the page from the data provided. } Quote Link to comment https://forums.phpfreaks.com/topic/219307-mod-rewrite-rule-for-custom-urls-userprofilephpuserid1001-to-example/#findComment-1137250 Share on other sites More sharing options...
CloudSex13 Posted November 20, 2010 Author Share Posted November 20, 2010 Thorpe, Thanks for your reply! That makes perfect sense, and it's so simple. Thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/219307-mod-rewrite-rule-for-custom-urls-userprofilephpuserid1001-to-example/#findComment-1137261 Share on other sites More sharing options...
CloudSex13 Posted November 21, 2010 Author Share Posted November 21, 2010 Thorpe, I tested the idea just now and realized it's not what I'm looking for. I'm looking for user's to be able to access their profile from a link like this one: http://www.example.com/userscustomurl Right now, they can access their profile from a link like this one: http://www.example.com/profile.php?id=1001 If you or anyone else has any further ideas how I could make this happen, please let me know. I appreciate your help! Quote Link to comment https://forums.phpfreaks.com/topic/219307-mod-rewrite-rule-for-custom-urls-userprofilephpuserid1001-to-example/#findComment-1137298 Share on other sites More sharing options...
trq Posted November 21, 2010 Share Posted November 21, 2010 The code I posted along with the rewrite rules you posted should allow what your after. Quote Link to comment https://forums.phpfreaks.com/topic/219307-mod-rewrite-rule-for-custom-urls-userprofilephpuserid1001-to-example/#findComment-1137373 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.