JohnnyDoomo Posted June 26, 2013 Share Posted June 26, 2013 Can someone here help me cut out parts of urls, using htaccess? I am looking to cut this type of url: http://krankr.com/clip/videos.php/photo/62921/Game_Videos/Routine-Oculus_Rift_Alpha_Gameplay_Trailer_HD/ down to this http://krankr.com/62921/Game_Videos/Routine-Oculus_Rift_Alpha_Gameplay_Trailer_HD/ and this type of url http://krankr.com/clip/showgallery.php/cat/503/Game_Videos/ down to this http://krankr.com/Game_Videos/ I'm not sure if someone can share a simple rule with me that I can simply copy and paste the words I want removed from urls like /photo/ and /videos.php/ or if a separate rule needs to be created for each and every type of item I want removed from urls. I need it so that if the old url is entered into a browser, it still works too. Can anybody help me accomplish this? Quote Link to comment https://forums.phpfreaks.com/topic/279613-hide-part-of-directory-structure-in-urls/ Share on other sites More sharing options...
requinix Posted June 26, 2013 Share Posted June 26, 2013 krankr.com/clip/videos.php/photo/62921/Game_Videos/Routine-Oculus_Rift_Alpha_Gameplay_Trailer_HD/ down to this krankr.com/62921/Game_Videos/Routine-Oculus_Rift_Alpha_Gameplay_Trailer_HD/ Rewrite "/numbers/category/title/" to "/clip/videos.php/photo/the stuff matched". krankr.com/clip/showgallery.php/cat/503/Game_Videos/ down to this krankr.com/Game_Videos/ That can only happen if the 503 you're rewriting is not necessary. If it is then you have to include it in the URL you want to show. To rewrite "/Game_Videos-503/" (as an example), Rewrite "/category-numbers/" (so long as it's not a real file or directory or other part of your site) to "/clip/showgallery.php/cat/numbers/category". For that "not a real file or directory" you can use RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-dbefore your RewriteRule. For the "other part of your site" all you have to do is put this RewriteRule (and the Conds) near the bottom of the list of other things being rewritten. (Don't forget to use [L]s for pretty much everything.) Give that a shot? Quote Link to comment https://forums.phpfreaks.com/topic/279613-hide-part-of-directory-structure-in-urls/#findComment-1438108 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.