great2gether Posted August 26, 2014 Share Posted August 26, 2014 Hello everybody, I am honestly quite a newb when it comes to mod_rewrite. We run a small social media page with different areas and I would like to change the URLs to something more clean and professional. User profiles look like this: http://www.sky-mp3.com/index.php?action=cm&siteid=59&wahl=artists&tat=details&keyid=477 siteid 59 is the artists list and the keyid at the end is the ID of the artist but should be like: http://www.sky-mp3.com/mischura or in worse case like: http://www.sky-mp3.com/user/mischura CMS pages look like this: http://www.sky-mp3.com/index.php?siteid=106 but should be like: http://www.sky-mp3.com/charts (page name instead of siteid) What I know so far: - I have to add something to the .htaccess file - I need to change something in the code (but I don`t know where) Im good he? What would be the first step on the path to clean URLs for me? I found alot of infos here and there but found nothing yet for this specific case. Kind regards from and thx in advance from Cologne Quote Link to comment https://forums.phpfreaks.com/topic/290654-trying-to-make-clean-urls-with-mod_rewrite-for-social-media-page-with-user-profiles-charts-more/ Share on other sites More sharing options...
great2gether Posted August 26, 2014 Author Share Posted August 26, 2014 Ah sorry I posted in the wrong category :/ It has to be in subcategory mod_rewrite How can I change it or delete this post and make a new one. Quote Link to comment https://forums.phpfreaks.com/topic/290654-trying-to-make-clean-urls-with-mod_rewrite-for-social-media-page-with-user-profiles-charts-more/#findComment-1488939 Share on other sites More sharing options...
CroNiX Posted August 26, 2014 Share Posted August 26, 2014 You won't be able to do all of that with mod_rewrite. mod_rewrite (apache) knows nothing about your php code, how it works, or what the ids, for example, translate to. All it knows is what the requested URL is and can only rewrite it using the same values basically. Like it has no way of knowing that siteid=59 translates to mischura as that's internal to your php app. It could rewrite something like http://www.sky-mp3.com/index.php?action=cm&siteid=59 to http://www.sky-mp3.com/cm/59 If your app used the username instead of the user ID, then it would work like you wanted, but you'd have to alter the way your app works and not use IDs and use the names of the entities instead. The app can get the user id based on the username. http://www.sky-mp3.com/index.php?action=cm&siteid=mischura could then be http://www.sky-mp3.com/cm/mischura Quote Link to comment https://forums.phpfreaks.com/topic/290654-trying-to-make-clean-urls-with-mod_rewrite-for-social-media-page-with-user-profiles-charts-more/#findComment-1488950 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.