Forum Moderators: phranque

Message Too Old, No Replies

Dynamic Content + Friendly URLs + SEO

How to make friendly URLs + manage SEO?

         

DarkEden Genesis

3:30 am on Apr 4, 2012 (gmt 0)

10+ Year Member



Hello everybody,
I have a website that generates dynamic urls for all content.

It uses functions to show the content on index.php page and every function is called by "action".

So, if the user wants to signup, there is a signup function for it.
If the user wants to browse downloads page, there is a downloads function.

Like this:
index.php?action=signup
index.php?action=downloads
index.php?action=news&type=type&id=id

In the last case are the articles.
The articles have a division: $type and $id, both numerics.

$type - can be update, new, event, etc... (update = 0, new = 1, event = 2, you get the point).
$id - it's the unique id for each article.

My question is: HOW and WHAT do I must to do in order to transform it all on friendly URLs?

As far as I have researched, I need to use a php function to deal with those urls plus mod rewrite.

incrediBILL

4:09 am on Apr 4, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



My question is: HOW and WHAT do I must to do in order to transform it all on friendly URLs?


Multiple ways to achieve the goal and those are kinda messy IMO.

Why not make them even simpler?

Like...

example.com/signup
example.com/downloads

etc.

One method for doing this is to make your entire site processed through index.php by default and use a case statement in index.php to either dispatch to the proper function or toss a 404 if the URL is borked.

When doing it all in PHP I opt for that kind of solution vs. bouncing back and forth in .htaccess because it's kind of silly to do a little here and a little there when you can do it all in either one place of the other.

As a project manager type, my first suggestion would be to flesh out your project on paper a little more, type out all the types of URLs you think you'll need for that project, then pick the method that's easiest and most flexible to take your project forward.

When sketching out the project, doesn't have to be 100% complete, just enough to get the general design on paper, or screen, so you can visualize where it's going before investing too much time in the technology and ending up with the wrong solution to the problem.

For instance, if I knew I was making a CMS that would have potentially thousands of SEO friendly keyword stuffed URLs, I probably wouldn't do much in .htaccess whatsoever.

However, if I knew the project would only need about 10 rewrite rules to process all URLs for the whole project, I might opt for close to a 100% .htaccess solution. Could be some rewrite rules, or as I've come to use more and more lately, a rewritemap function which really rocks when it comes to situations like this unless your URLs with ever have a space or other special characters in them, then skip rewritemaps IMO.

See what I mean?

Pick the right solution for the right problem and you'll be happier in the end.

As far as performance goes, once you're already in PHP a couple of extra lines to dispatch to the proper code, vs. using .htaccess, is pretty irrelevant.

DarkEden Genesis

4:32 am on Apr 4, 2012 (gmt 0)

10+ Year Member



Bill, I don't understand much about PHP or rewrite rules.
So, I wouldn't be able to know what's the best solution.
As I said, from my researches I learned that would need to use both: PHP + mod_rewrite (together).

Now you come and say it's possible to use only one of those solutions and it starts to make sense.
And more, I think that PHP solution would be smarter.

I couldn't understand your method:
"One method for doing this is to make your entire site processed through index.php by default and use a case statement in index.php to either dispatch to the proper function or toss a 404 if the URL is borked."


From what I can get from it, is that whole content from my website must be processed through index.php and it actually happens, like you can see from the examples.
What would be that "case statement" ?
Dispatch?

Please, help me to find the solution.
Help me to write and understand which code must be written.
I don't know how to fix it, but know the need and be unable to repair is a bad feeling.

Thanks

DarkEden Genesis

8:43 pm on Apr 4, 2012 (gmt 0)

10+ Year Member



I still stuck here.

Anyone can help me?

lucy24

9:32 pm on Apr 4, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You might want to take the question next door to the PHP forum. If someone is fluent in php but won't touch Apache with a barge pole, they may never see your question over here. Especially when there's no mention of PHP in the subject line.

DarkEden Genesis

9:54 pm on Apr 4, 2012 (gmt 0)

10+ Year Member



Isn't it able to be solved with mod_rewrite?

If so, apache is one of the ways.

I honestly don't know how to solve my issue, if you have some specific idea let me know Lucy.

Anyway, I will start a topic at PHP.

Thanks

DarkEden Genesis

3:18 am on Apr 5, 2012 (gmt 0)

10+ Year Member




System: The following message was spliced on to this thread from: http://www.webmasterworld.com/php/4437323.htm [webmasterworld.com] by eelixduppy - 11:43 am on Apr 5, 2012 <small>(est -5)</small>


Hello everybody,

My website generates dynamic urls for all content.

It uses functions to show the content on index.php page and EVERY function is called by "ACTION".

So, if the user wants to signup, there is a signup action calling it's function.
If the user wants to browse downloads page, there is a downloads action calling it's function.

Like this:
index.php?action=signup
index.php?action=downloads
index.php?action=news&type=type&id=id

The last example, reffer to the articles.
The articles have a division: $type and $id, both numerics.

$type - can be updates, news, events, etc... (update = 0, new = 1, event = 2, you get the point).
$id - it's the unique id for each article.

Real URL:
url.com/index.php?action=news&type=1&id=22

Desired URL:
url.com/$TYPE/$id/$title-of-the-notice

$type = updates, news, events, etc...
$id = unique notice id
$title = unique notice title

As far as I have researched, I need to use a php function to proccess those urls plus mod rewrite.

My question is: HOW and WHAT do I must to do in order to transform it all on friendly URLs?

[edited by: eelixduppy at 4:48 pm (utc) on Apr 5, 2012]

eelixduppy

4:47 pm on Apr 5, 2012 (gmt 0)




Real URL:
url.com/index.php?action=news&type=1&id=22

Desired URL:
url.com/$TYPE/$id/$title-of-the-notice


I've moved this over from PHP. From this alone, it is clear you are looking for an apache solution here. PHP does not produce what you are looking for above...

This should help get you started with mod_rewrite: [httpd.apache.org...]