limitphp Posted December 15, 2008 Share Posted December 15, 2008 I'm building a music website, and I'm going to have an artist page that will talk about each of the artists that sells music on my site. Right now I'm thinking about 1. creating a page called artist.php and for each artist I'll just have the link with an artistID, like: <a href='artist.php?artistID=1'>Band Name</a> Of course, this would mean, that people could just copy that link and change the artistID to whatever they wanted. The other alternative, i think, is, 2. I've seen alot of sites that have pages that seem to be named on the fly, temporarily or something. Like digg.com, for example.....when you click on a digg topic, the name of the page is called whatever that digg is called. Like digg.com/storyname/ Obviously they don't have pages named after their stories. Are they creating like temporary pages or something? Should I just use number 1 method? If so, do I need to protect against sql injections and other stuff? Quote Link to comment https://forums.phpfreaks.com/topic/137103-logic-help/ Share on other sites More sharing options...
premiso Posted December 15, 2008 Share Posted December 15, 2008 The number 1 method is not SEO friendly. Search: PHP htaccess SEO Friendly URLS You should find some good mod_rewrite examples of how to do what you want. Quote Link to comment https://forums.phpfreaks.com/topic/137103-logic-help/#findComment-716112 Share on other sites More sharing options...
Mchl Posted December 15, 2008 Share Posted December 15, 2008 Read about mod_rewrite for method 2 You should always protect yourself against sql injections. Always. Quote Link to comment https://forums.phpfreaks.com/topic/137103-logic-help/#findComment-716116 Share on other sites More sharing options...
limitphp Posted December 15, 2008 Author Share Posted December 15, 2008 The number 1 method is not SEO friendly. Search: PHP htaccess SEO Friendly URLS You should find some good mod_rewrite examples of how to do what you want. Ok, I'm looking it up.... what is SEO? Quote Link to comment https://forums.phpfreaks.com/topic/137103-logic-help/#findComment-716119 Share on other sites More sharing options...
premiso Posted December 15, 2008 Share Posted December 15, 2008 Search Engine Optimization. Makes your site rank higher on search engines such as google Quote Link to comment https://forums.phpfreaks.com/topic/137103-logic-help/#findComment-716121 Share on other sites More sharing options...
limitphp Posted December 15, 2008 Author Share Posted December 15, 2008 Ok, so I was reading about it. It said you have to create a file called .htaccess in the directory of where the pages are located. Then it said type in this in .htaccess: RewriteEngine on and then it said here's an example of a rule: RewriteRule /articles/([0-9]+) /articles.php?id=$1 and This will replace http://www.yoursite.com/articles/1/ with http://www.yoursite.com/articles.php?id=1 The exact opposite of what i would need. so basically, I need mine to change ex) www.greckle.com/artist.php?artistID=1 into: www.greckle.com/artistName or www.greckle.com/artist/artistName/ Is it possible to take the artistID in the rewrite and get the artistName for the url? Quote Link to comment https://forums.phpfreaks.com/topic/137103-logic-help/#findComment-716136 Share on other sites More sharing options...
Mchl Posted December 15, 2008 Share Posted December 15, 2008 You would have to change your script code, to accept artist's name instead of id. Rewrite can't do that. and This will replace http://www.yoursite.com/articles/1/ with http://www.yoursite.com/articles.php?id=1 No. The user will see http://www.yoursite.com/articles/1/ in his browser, but http://www.yoursite.com/articles.php?id=1 will actually be called. Quote Link to comment https://forums.phpfreaks.com/topic/137103-logic-help/#findComment-716142 Share on other sites More sharing options...
limitphp Posted December 15, 2008 Author Share Posted December 15, 2008 I think I'll allow bands to have the same names. So, if there was a Last Free Exit in Houston, and a Last Free Exit in San Francisco, thats ok. My website will probably be used by small bands with no record labels, or bands with small record labels. So the chances of bands with the same names is probably likely. Which is fine, becuase on the main page it lists all the songs, band names, but it also list the members names. So people would be able to tell that these "two bands with he same name have different members, and they probably are different bands". And eventually, if one or both of the bands starts selling alot of songs, one of them will probably change their name. So, I'll need to use the "artist.php?artistID=" right now. Could I pass both? like artist.php?artistID=1&artistName=The Strokes But then only display the artistName on the rewritten URL? If so, can you help me with that? Quote Link to comment https://forums.phpfreaks.com/topic/137103-logic-help/#findComment-716153 Share on other sites More sharing options...
limitphp Posted December 15, 2008 Author Share Posted December 15, 2008 ok....I set the rewrite in apache...now wamp server accpets the htaccess file. Quote Link to comment https://forums.phpfreaks.com/topic/137103-logic-help/#findComment-716179 Share on other sites More sharing options...
Mchl Posted December 15, 2008 Share Posted December 15, 2008 Enable mod_rewrite Click on WampServer icon in tray, select Apache > Apache modules > rewrite_module Quote Link to comment https://forums.phpfreaks.com/topic/137103-logic-help/#findComment-716183 Share on other sites More sharing options...
limitphp Posted December 15, 2008 Author Share Posted December 15, 2008 Enable mod_rewrite Click on WampServer icon in tray, select Apache > Apache modules > rewrite_module thanks....its back up now.... Quote Link to comment https://forums.phpfreaks.com/topic/137103-logic-help/#findComment-716187 Share on other sites More sharing options...
limitphp Posted December 15, 2008 Author Share Posted December 15, 2008 ok, here goes.... RewriteRule ^artist/([0-9]+)/$ /artist.php?artistID=$1 I'm willing to settle for just www.greckle.com/artist/xx/ I don't understand.....do you need to rewrite rules? One that rewrites a url in case someone types it in...like if someone types in www.greckle.com/artist/2 and rewrites it like www.greckle.com/artist.php?artistID=2 and then one that rewrites it using the faux directories so, in our website, if we are taking them to www.greckle.com/artist.php?artistID=2 we want it to look like this: www.greckle.com/artist/2 I'm confused....I'm reading through some tutorials.....and i tried looking for some on phpfreaks, but I can't find any on mod rewrites, excpet for a super short one that briefly mentions it involving security Quote Link to comment https://forums.phpfreaks.com/topic/137103-logic-help/#findComment-716194 Share on other sites More sharing options...
premiso Posted December 15, 2008 Share Posted December 15, 2008 ok, here goes.... RewriteRule ^artist/([0-9]+)/$ /artist.php?artistID=$1 I'm willing to settle for just www.greckle.com/artist/xx/ I don't understand.....do you need to rewrite rules? One that rewrites a url in case someone types it in...like if someone types in www.greckle.com/artist/2 and rewrites it like www.greckle.com/artist.php?artistID=2 and then one that rewrites it using the faux directories so, in our website, if we are taking them to www.greckle.com/artist.php?artistID=2 we want it to look like this: www.greckle.com/artist/2 I'm confused....I'm reading through some tutorials.....and i tried looking for some on phpfreaks, but I can't find any on mod rewrites, excpet for a super short one that briefly mentions it involving security The idea behind SEO is to have keywords part of the URL. What I usually do is take something unique, such as the artist name, and convert it to an seo url and store this in the DB to access it. So let's say you have something like "Jack's High End Band" for an artitst title. I would create something to make it "jacks-high-end-band" Then create the url http://yoursite.com/artist/jacks-high-end-band Then you just select * from tbl where seo_artist = 'jacks-high-end-band'; So basically when an artist is inserted you have a function in your code to convert the artist to seoFriendlyArtist and return a string like the above. Anyhow just figured I would throw that out there incase you were interested =) If you would like a function that converts stuff to seofriendly urls let me know and I will clean up my function and post it here. Quote Link to comment https://forums.phpfreaks.com/topic/137103-logic-help/#findComment-716197 Share on other sites More sharing options...
limitphp Posted December 16, 2008 Author Share Posted December 16, 2008 ok, here goes.... RewriteRule ^artist/([0-9]+)/$ /artist.php?artistID=$1 I'm willing to settle for just www.greckle.com/artist/xx/ I don't understand.....do you need to rewrite rules? One that rewrites a url in case someone types it in...like if someone types in www.greckle.com/artist/2 and rewrites it like www.greckle.com/artist.php?artistID=2 and then one that rewrites it using the faux directories so, in our website, if we are taking them to www.greckle.com/artist.php?artistID=2 we want it to look like this: www.greckle.com/artist/2 I'm confused....I'm reading through some tutorials.....and i tried looking for some on phpfreaks, but I can't find any on mod rewrites, excpet for a super short one that briefly mentions it involving security The idea behind SEO is to have keywords part of the URL. What I usually do is take something unique, such as the artist name, and convert it to an seo url and store this in the DB to access it. So let's say you have something like "Jack's High End Band" for an artitst title. I would create something to make it "jacks-high-end-band" Then create the url http://yoursite.com/artist/jacks-high-end-band Then you just select * from tbl where seo_artist = 'jacks-high-end-band'; So basically when an artist is inserted you have a function in your code to convert the artist to seoFriendlyArtist and return a string like the above. Anyhow just figured I would throw that out there incase you were interested =) If you would like a function that converts stuff to seofriendly urls let me know and I will clean up my function and post it here. Wait a minute....I thought the apache server converts the url into an easy to read url. I thought you just have to put the rules in a htaccess file? Quote Link to comment https://forums.phpfreaks.com/topic/137103-logic-help/#findComment-716327 Share on other sites More sharing options...
premiso Posted December 16, 2008 Share Posted December 16, 2008 ok, here goes.... RewriteRule ^artist/([0-9]+)/$ /artist.php?artistID=$1 I'm willing to settle for just www.greckle.com/artist/xx/ I don't understand.....do you need to rewrite rules? One that rewrites a url in case someone types it in...like if someone types in www.greckle.com/artist/2 and rewrites it like www.greckle.com/artist.php?artistID=2 and then one that rewrites it using the faux directories so, in our website, if we are taking them to www.greckle.com/artist.php?artistID=2 we want it to look like this: www.greckle.com/artist/2 I'm confused....I'm reading through some tutorials.....and i tried looking for some on phpfreaks, but I can't find any on mod rewrites, excpet for a super short one that briefly mentions it involving security The idea behind SEO is to have keywords part of the URL. What I usually do is take something unique, such as the artist name, and convert it to an seo url and store this in the DB to access it. So let's say you have something like "Jack's High End Band" for an artitst title. I would create something to make it "jacks-high-end-band" Then create the url http://yoursite.com/artist/jacks-high-end-band Then you just select * from tbl where seo_artist = 'jacks-high-end-band'; So basically when an artist is inserted you have a function in your code to convert the artist to seoFriendlyArtist and return a string like the above. Anyhow just figured I would throw that out there incase you were interested =) If you would like a function that converts stuff to seofriendly urls let me know and I will clean up my function and post it here. Wait a minute....I thought the apache server converts the url into an easy to read url. I thought you just have to put the rules in a htaccess file? It does, but if you want SEO friendly URLS to help boost your seo ranking, than you want to have the artist in the url. It is the same setup, except on the artist.php page you check the returned get data against an "Seo_artist" field in the DB. If you do not care about that, artist/id will work just fine for you. Quote Link to comment https://forums.phpfreaks.com/topic/137103-logic-help/#findComment-716714 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.