Jump to content

Logic help


limitphp

Recommended Posts

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?

 

 

 

 

 

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

You would have to change your script code, to accept artist's name instead of id. Rewrite can't do that.

 

 

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.

Link to comment
Share on other sites

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?

 

 

 

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.