I have a website that generates dynamic urls for all content.
It uses a function to show the content on index.php page and it's called by "action".
So, if the user wants to signup, there is a signup function calling it. If the user want's to browse downloads page, there is a downloads function calling it.
Something like this:
index.php?action=signup
index.php?action=downloads
index.php?action=news&type=type&id=id
In the last case are the news. The news are divided by type and ID, both numerics.
Type can be: article, update, etc.
My question is: HOW and WHAT must I do in order to transform it all on friendly URLs?
Presuming you are on an apache server, you will want to use a .htaccess file, and a method of using rules to rewrite URLs, not surprisingly called RewriteRule.
There's a ton of information through google if you search for .htaccess RewriteRule, but a great starting point is http://corz.org/serv/tricks/htaccess2.php.
You will essentially end up by putting a file called .htaccess in your public web files folder, with something like this:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(?:/(.*)){1,3} index.php?action=$1&type=$2&id=$3 [R,NC]
Note: I've not tested the above, and it will differ depending on how you want your pretty link to look.
First - url.com/index.php?action=signup (url.com/register) Second - url.com/index.php?action=news&id=$id&title=$title (url.com/news/$id/title-of-the-notice-with-hifens)
Hifens will come from a PHP function or the rewrite rule? How to fix CSS problem after putting these dirs? How would be each rule - Darkeden 2012-04-10 15:55
RewriteRule ^register$ index.php?action=register RewriteRule ^news/(\d+)/([a-zA-Z0-9-]+)$ index.php?action=news&id=$1&title=$2
Note: This will not work if you have a trailing slash - you can figure out what you want to do here (either add one optionally with /? or just create another rule to not allow them, for instance)
In your CSS you will have to just change the paths to reflect what the browser will now see. Use absolute paths, starting with a - LeonardChallis 2012-04-10 17:36
With some rewrite rules I can make "/register" avaliable, but it isn't enough, since I would need to manually update links.
Maybe you can help me to find out what I really need.
PROBLEM Current url: url.com/index.php?action=signup Desired url: url.com/register
How to make my website SHOWS "/register" as a link, not only as a possible path? I mean, when my website generates a dynamic link, it doesn't respect SEO rules. How to make it respects SEO? How to make it generates "/register" instead of "/index.php?action=signup" - Darkeden 2012-04-07 00:36