imgrooot Posted August 18, 2016 Share Posted August 18, 2016 Say below is my normal html href link. How would you turn this into a pretty URL using .htaccess? Also if I understand it correctly, this link will also have to be changed to match the pretty url. What would the new link look like? <a href="shop.php?type=45&name=belts">Belts</a> Quote Link to comment https://forums.phpfreaks.com/topic/301928-rewriting-pretty-urls-too-many-examples-out-there-dont-show-the-entire-process/ Share on other sites More sharing options...
Jacques1 Posted August 18, 2016 Share Posted August 18, 2016 (edited) What would the new link look like? Designing the URLs is your job. “Pretty URLs” are just an abstract concept for URLs that are optimized for readability. How exactly your URLs should look like is something only you know. A good guideline is Cool URIs don't change from Tim Berners-Lee himself. Edited August 18, 2016 by Jacques1 Quote Link to comment https://forums.phpfreaks.com/topic/301928-rewriting-pretty-urls-too-many-examples-out-there-dont-show-the-entire-process/#findComment-1536283 Share on other sites More sharing options...
imgrooot Posted August 18, 2016 Author Share Posted August 18, 2016 Designing the URLs is your job. “Pretty URLs” are just an abstract concept for URLs that are optimized for readability. How exactly your URLs should look like is something only you know. A good guideline is Cool URIs don't change from Tim Berners-Lee himself. I've been pulling my hair trying to figure this out and so far unsuccessful. It would be very helpful if someone knowledgeable about this can help me out. Every professional site I see out there has pretty urls, as oppose to what I have above. Even phpfreaks site has pretty urls. How would I go on about doing that based on the link I provided above? So far all I got is this. How would I change the above link to match this? RewriteRule ^([a-z]+)\/([0-9]+)\/?$ shop.php?type=$1&name=$2 [NC] Quote Link to comment https://forums.phpfreaks.com/topic/301928-rewriting-pretty-urls-too-many-examples-out-there-dont-show-the-entire-process/#findComment-1536284 Share on other sites More sharing options...
Jacques1 Posted August 18, 2016 Share Posted August 18, 2016 This makes no sense. You're now assuming an alphabetical type followed by a numerical name, but your link above has the exact opposite (a numerical type and an alphabetical name). Again: You have it backwards. You tell us your the URLs should look like. And then we can tell you how to implement them. Guessing from your example, it seems you want this: /belts/45 So first the category, then the numerical type. Correct? Quote Link to comment https://forums.phpfreaks.com/topic/301928-rewriting-pretty-urls-too-many-examples-out-there-dont-show-the-entire-process/#findComment-1536285 Share on other sites More sharing options...
imgrooot Posted August 18, 2016 Author Share Posted August 18, 2016 This makes no sense. You're now assuming an alphabetical type followed by a numerical name, but your link above has the exact opposite (a numerical type and an alphabetical name). Again: You have it backwards. You tell us your the URLs should look like. And then we can tell you how to implement them. Guessing from your example, it seems you want this: /belts/45 So first the category, then the numerical type. Correct? Well yes like that, although belts can come after the 45. Like this. shop/45/belts Quote Link to comment https://forums.phpfreaks.com/topic/301928-rewriting-pretty-urls-too-many-examples-out-there-dont-show-the-entire-process/#findComment-1536286 Share on other sites More sharing options...
imgrooot Posted August 18, 2016 Author Share Posted August 18, 2016 So can someone tell me how to do it? Quote Link to comment https://forums.phpfreaks.com/topic/301928-rewriting-pretty-urls-too-many-examples-out-there-dont-show-the-entire-process/#findComment-1536307 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.