imgrooot Posted August 8, 2020 Share Posted August 8, 2020 This is more of an SEO question. I have a site with couple hundred categories within each city. I was wondering what the best approach is to do them? www.mysite.com/browse/apples?city=new-york www.mysite.com/browse/new-york?category=apples Which one is the better way to do it for seo purposes? If it's the first method, that would mean I would have to create couple hundred pages for those categories yes? Quote Link to comment https://forums.phpfreaks.com/topic/311294-do-i-have-to-create-a-new-page-for-every-single-category/ Share on other sites More sharing options...
requinix Posted August 8, 2020 Share Posted August 8, 2020 SEO doesn't care about the URL. It's a myth. The second one looks better. Either way you never create "hundreds of pages". Every single one should use URL rewriting to go through a single PHP script. For example, you can tell your web server that /browse/thing should map to /browse.php?city=thing (and append the ?category=apples). Then all you need is the single file to handle everything. Quote Link to comment https://forums.phpfreaks.com/topic/311294-do-i-have-to-create-a-new-page-for-every-single-category/#findComment-1580456 Share on other sites More sharing options...
imgrooot Posted August 9, 2020 Author Share Posted August 9, 2020 (edited) 5 hours ago, requinix said: SEO doesn't care about the URL. It's a myth. The second one looks better. Either way you never create "hundreds of pages". Every single one should use URL rewriting to go through a single PHP script. For example, you can tell your web server that /browse/thing should map to /browse.php?city=thing (and append the ?category=apples). Then all you need is the single file to handle everything. Really? That's how I had it originally but now I changed it to have a separate page for each city. Guess I'll change it back. Second question, is it okay to have an ID of a city and category as oppose to the name in the URL? Like this. /browse.php?city=123&category=456 Having an ID would make it a lot easier to retrieve data. Edited August 9, 2020 by imgrooot Quote Link to comment https://forums.phpfreaks.com/topic/311294-do-i-have-to-create-a-new-page-for-every-single-category/#findComment-1580457 Share on other sites More sharing options...
requinix Posted August 9, 2020 Share Posted August 9, 2020 33 minutes ago, imgrooot said: Really? That's how I had it originally but now I changed it to have a separate page for each city. Guess I'll change it back. Answer it this way: What is the hierarchy of the actual data? /browse/apples?city=new-york suggests the person is browsing apples and wants to see the ones for New York. /browse/new-york?category=apples suggests the person is browsing things about New York and wants to see the ones about apples. Only one of those should make sense - or at least make noticeably more sense than the other. 33 minutes ago, imgrooot said: Second question, is it okay to have an ID of a city and category as oppose to the name in the URL? Like this. /browse.php?city=123&category=456 Having an ID would make it a lot easier to retrieve data. ...which is why sites use IDs. But labels are nice for people to read (SEO doesn't care about URLs but humans do), which is why sites don't use just the IDs but also the labels too. Such as /topic/311294-do-i-have-to-create-a-new-page-for-every-single-category/ Use the ID, but verify that the rest of it matches (and redirect if it does not). Quote Link to comment https://forums.phpfreaks.com/topic/311294-do-i-have-to-create-a-new-page-for-every-single-category/#findComment-1580458 Share on other sites More sharing options...
imgrooot Posted August 9, 2020 Author Share Posted August 9, 2020 (edited) 22 minutes ago, requinix said: Answer it this way: What is the hierarchy of the actual data? /browse/apples?city=new-york suggests the person is browsing apples and wants to see the ones for New York. /browse/new-york?category=apples suggests the person is browsing things about New York and wants to see the ones about apples. Only one of those should make sense - or at least make noticeably more sense than the other. ...which is why sites use IDs. But labels are nice for people to read (SEO doesn't care about URLs but humans do), which is why sites don't use just the IDs but also the labels too. Such as /topic/311294-do-i-have-to-create-a-new-page-for-every-single-category/ Use the ID, but verify that the rest of it matches (and redirect if it does not). 1. What I meant was that originally I had a single browse.php page and included cities as parameters. For e.g. /browse.php?city=new-york. So I changed it to having each city as a separate page like /browse.php/new-york.php. So I am asking if I should leave it as is or change it back? 2. I am using IDs to retrieve the results from the database. If a city parameter ID is ''123", I can grab it form the url and search all the records in that city from the database. Isn't that how it's suppose to be done? If I use both, it would look like this. /browse.php?city=new-york&id=123. I don't know how to do pretty urls so I can't make it like your example. Edited August 9, 2020 by imgrooot Quote Link to comment https://forums.phpfreaks.com/topic/311294-do-i-have-to-create-a-new-page-for-every-single-category/#findComment-1580459 Share on other sites More sharing options...
requinix Posted August 9, 2020 Share Posted August 9, 2020 38 minutes ago, imgrooot said: 1. What I meant was that originally I had a single browse.php page and included cities as parameters. For e.g. /browse.php?city=new-york. So I changed it to having each city as a separate page like /browse.php/new-york.php. So I am asking if I should leave it as is or change it back? One browse.php that handles /browse/whatever. Quote 2. I am using IDs to retrieve the results from the database. If a city parameter ID is ''123", I can grab it form the url and search all the records in that city from the database. Isn't that how it's suppose to be done? If I use both, it would look like this. /browse.php?city=new-york&id=123. I don't know how to do pretty urls so I can't make it like your example. browse.php?city=123 If the page is valid (city #123 exists) then the next step is to figure out what the canonical URL for the page should be. Namely /browse/city-name. If there's a category then that too, which you can handle as just ?category=123 because people don't care about query strings. If the canonical URL does not match the actual URL then redirect. Quote Link to comment https://forums.phpfreaks.com/topic/311294-do-i-have-to-create-a-new-page-for-every-single-category/#findComment-1580461 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.